# CUSTOM_ID for HTML breaks "next line" in LaTeX

If in Org, I have

**** Scancode
:PROPERTIES:
:CUSTOM_ID: input-types-scancode
:END:

Representing a Scancode is simple.


the ID properly gets set in HTML:

<ol class="org-ol">
<li><a id="input-types-scancode"></a><a id="org9e5f241"></a>Scancode<br />
<div class="outline-text-5" id="text-input-types-scancode">
<p>
Representing a Scancode is simple.


But the LaTeX breaks:

\begin{enumerate}
\item Scancode
\label{sec:org0a033f2}
Representing a Scancode is simple.


However, if I add a newline in the Org:

**** Scancode

:PROPERTIES:
:CUSTOM_ID: input-types-scancode
:END:

Representing a Scancode is simple.


it fixes the LaTeX:

\begin{enumerate}
\item Scancode
\label{sec:org9bf670a}

Representing a Scancode is simple.


but breaks the ID in the HTML:

<ol class="org-ol">
<li><a id="orga8c4156"></a>Scancode<br />
<div class="outline-text-5" id="text-2-5-1-1">
<p>
Representing a Scancode is simple.


How can I keep the ID in HTML while keeping the content of the LaTeX entry on the next line?

My #+OPTIONS: are

#+OPTIONS: ':nil *:t -:t ::t <:t H:3 \n:nil ^:t arch:headline
#+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

• cannot reproduce. Could you share more of your Org file? Aug 4 '19 at 0:41
• @dangom added my Options to post
– Aly
Aug 4 '19 at 0:54
• I can't reproduce it either. How does the .tex file look? What version of org-mode are you using? Aug 4 '19 at 3:02
• 9.1.9. I've edited the post to add examples of the TeX generated at those points. @NickD
– Aly
Aug 4 '19 at 3:15
• OK, now I see what you are trying to do (BTW, if you had posted a more complete org file to begin with, the back-and-forth could have been avoided. In particular, you need the higher-level headlines to see the "problem"). Aug 4 '19 at 12:30

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: 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.

• It does add a newline, but it doesn't have the spacing between the list item and the content that I want; instead of having the spacing that paragraphs have between them it just has normal line spacing. I'll use it for now though.
– Aly
Aug 4 '19 at 17:11
• Also, is it possible to have some Elisp I can include that does this automatically whenever I have a section deeper than my H with properties?
– Aly
Aug 4 '19 at 17:18
• Actually, inserting double #+LATEX:s and then a newline in the org works, i.e. **** Scancode␤␤:PROPERTIES:...␤␤#+LATEX:␤#+LATEX:␤␤ Representing a Scancode is simple.
– Aly
Aug 4 '19 at 17:40
• @Soren: I expanded my answer to cover the questions in the comments - PTAL. Aug 4 '19 at 19:54