This is not really a problem with either org or LaTeX.
You have set H:3
which makes fourth-level headlines into list items of some sort. You have chosen num:t
which says that the sections should be numbered. In that case, the LaTeX exporter chooses the enumerate
environment for "deep" sections.
So far, so good.
But that makes the whole section (headline and all) into an \item
in that environment:
\begin{enumerate}
\item Scancode
\label{sec:orgfbe7707}
Representing a Scancode is simple.
\end{enumerate}
So org has preserved the line structure, but that is irrelevant to LaTeX: it just formats the item as one continuous paragraph.
Try the following:
#+OPTIONS: ':nil *:t -:t ::t <:t H:3 \n:nil ^:t arch:headline
#+OPTIONS: author:t broken-links:nil c:nil creator:nil
#+OPTIONS: d:nil date:t e:t email:nil f:t html-style:nil
#+OPTIONS: inline:t num:t p:nil pri:nil prop:nil stat:t tags:t
#+OPTIONS: tasks:t tex:t timestamp:t title:t toc:t todo:t |:t
* Section foo
foo
** Subsection bar
bar
*** Subsubsection baz
baz
**** Scancode
:PROPERTIES:
:CUSTOM_ID: input-types-scancode
:END:
#+LATEX: \newline
Representing a Scancode is simple.
That will insert a \newline
into the .tex file, so it becomes a part of the LaTeX markup. At that point, LaTeX has no option but to obey.
What #+LATEX:
does is it tells to the exporter to insert its value "right there". The trick is to know enough LaTeX to know what that value should be.
Above I used \newline
but you can use other LaTeX markup, e.g. if you want to make the text after it a new paragraph, you can use \par
instead - see this TeX SE question for details of what \par
does differently.
IMO, that would be a better solution to the question you pose in your first comment than the double #+LATEX:
solution in your third comment:
**** Scancode
:PROPERTIES:
:CUSTOM_ID: input-types-scancode
:END:
#+LATEX: \par
Representing a Scancode is simple.
You can use the org mode LaTeX exporter for simple, straightforward exports and it works very well. But it does not (and was not meant to) hide the underlying LaTeX: as soon as you require something out of the ordinary, then you will have to resort to manual tweaks like the ones above, and for that you will need to know some LaTeX.
Re: your second question about automating the insertion with elisp: yes, you can - you can do just about anything with elisp. The question is: do you want to? For me, the answer is "no": I would just define an emacs abbrev and invoke it manually. But if you want to go full automation, I won't stand in your way :-)
BTW, the reason that adding an empty line between the headline and the properties drawer broke the HTML export is that it breaks org mode syntax:
scheduling information (SCHEDULED:
, DEADLINE:
) and properties drawers
have to follow the headline in that order and there can be no empty lines between them. A useful tool is org-lint
: just do M-x org-lint RET
in your buffer to find out if there are such problems.