0

Good day!

New emacs user here.

I am writing a contract in org mode and exporting it to PDF (assume that currently no latex plugins or settings are applied(in my org file heading) to the document as they do not affect the output of the PDF).

Most of the things are going good, however, I am having a little issue with org headings.

* Heading 1
** Heading 2
*** Heading 3
*** Heading 3
*** Heading 3
*** Heading 3
*** Heading 3
*** Heading 3
** Heading 2
** Heading 2

As you might guess, the heading 1 gets bold.

The heading 2 gets bold as well.

But what makes me struggle is the third heading, I don't want it to be bold, because this heading doesn't act as a heading in my file, it is where the text goes.

enter image description here

Org-pdf export output looks like this:

enter image description here

So far, the workaround was to make the Heading 3 into a bullet list. It is not made bold, but also I don't get the numbering, which doesn't look professional.

enter image description here

I can live without numbers, but still would be curious to know if I can get normal (i.e. not bold) headings.

Thanks!

Btw, the text in the document is Lithuanian :)

EDIT

Attempt 1

According to the comment, trying to use plain lists. Doesn't do the job.

enter image description here

Attempt 2

Trying to use this This method, however, as it says in the manual, after using in my case:

#+OPTIONS: H:2

The *** headings become ordinary list items and start from 1 instead of 1.1.1. as so:

enter image description here

Attempt 3

Thanks to NickD, the problem was solved. I really recommend looking into that answer just for the sake of learning something new about what org-mode and latex is capable of, even if you don't have my particular problem.

enter image description here

I can now fix my whole document and happily present it to the client :)

I am glad I persisted with Emacs and didn't just switch to Word as soon as things got tough. I like emacs. I like this community.

Be happy y'all!

8
  • Why not make them a numbered list? Called plain ordered lists here orgmode.org/manual/Plain-Lists.html
    – Rusi
    Commented Sep 5, 2021 at 5:31
  • Thanks for the idea. I will try it in a second and show the result in the original post. BUT I also hope and believe that org has other solution, because typing lists manually that don't update upon deletion of list items feels wrong. Might as well use Word then :)
    – Arvydas
    Commented Sep 5, 2021 at 5:36
  • Just C-c C-c - it will renumber. To be fair Word also renumbers (I believe 😅). There may also be a "real time" update making the C-c C-c unnecessary.
    – Rusi
    Commented Sep 5, 2021 at 5:40
  • Please see my edit of the original post. Did I understand you right? Because C-c C-c doesn't renumber when I delete one of the 1.1.1 lines.
    – Arvydas
    Commented Sep 5, 2021 at 5:45
  • Don't write 1.1.n. Just write n. Of course if you want to write 1 2 3... And have org pretend the outer heading part that's a next level of sophistication. Ask another q for that
    – Rusi
    Commented Sep 5, 2021 at 5:46

1 Answer 1

3

I don't know what you mean by "assume that current[l]y no latex plugins or settings are applied to the document as they do not affect the output of the PDF" but taking it literally, it is not true: Org mode converts the Org mode file to a TeX file first and then processes the TeX file through some processor (e.g. pdflatex) to produce the PDF file. So even if there are no settings in the Org mode file that modify the TeX output, the default LaTeX exporter applies plenty of settings that do affect the PDF output: check the TeX file that is produced and you will see what I mean.

That said, Org mode with the default H:3 setting and the default article class turns top level headings into sections, 2nd-level headings into subsections and 3rd-level headings into subsubsections. By default, LaTeX formats section headings in bold, so you get what you have described.

You can affect the output by e.g. changing the default class to one of the other standard LaTeX classes (e.g. book or report) by adding an options setting to your Org mode file:

#+LATEX_CLASS: report

or (as you have found out already) by changing the level at which the sectioning stops:

#+OPTIONS: H:2

making 3rd-level headings not into subsubsections but plain lists.

All these ways are limited: there is a conventional way that Org mode exports to LaTeX and if you are happy with that (or with the simple extensions above), then you don't have to know any LaTeX. But if you want to change the format in ways that the various options cannot accommodate, you can still do so but you have to know some LaTeX.

In this particular case, you can tell LaTeX to just not use a bold font for \subsubsection headings, by redefining the \subsubsection command. First, you have to find where the command is defined for the class in question. For the default article class, use the following command to find the class file:

$ kpsewhich article.cls
/usr/share/texlive/texmf-dist/tex/latex/base/article.cls

Then visit the file that kpsewhich told you and find the definition of the \subsubsection macro:

\newcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\normalsize\bfseries}}

The final macro, \bfseries, selects the bold font, so all you have to do is redefine \subsubsection without it.

The best way to redefine LaTeX commands is to create your own style file. So create a file called (say) mysubsubsection.sty in the same directory as your Org mode file and add the following contents:

\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\normalsize}}

All I did was to get rid of the \bferies macro call and to change \newcommand to \renewcommand since I am redefining an existing macro.

That's it for the LaTeX part. Now you have to make sure that the style file is used when processing your Org mode document. You do that by adding the following at the top of your file:

#+LATEX_HEADER: \usepackage{mysubsubsection}

...

Now when you export your Org mode file to PDF, it is going to be converted to a LaTeX file first (be sure to examine the .tex file produced and see that the only difference is that there is an extra \usepackage line near the top). Now when LaTeX processes the .tex file to a .pdf file, it will use the new definition of \subsubsection and produce normal (i.e. not bold) headings for them.

This is a powerful way to change the appearance of your PDF document (it is not going to do anything if you export to HTML, or ODF or anything else), but you have to know a bit about LaTeX in order to use it effectively. But IMO, you have to know a bit about LaTeX in order to be able to write your documents in Org mode effectively without much LaTeX fiddling: that sounds contradictory but I am convinced it is true. I hope that the answer is useful, despite the fact that it is mostly about LaTeX, not about Org mode: but it's the connection to the latter that I am interested in, so I hope it's not off-topic for Emacs SE.

8
  • Vow Quite an answer! But yes as you suspect the mods in a mood can delete an answer when it's helpful but tangentially topical. I certainly hope to use it. (Just finished a paper submission -- org-latex -- and didn't quite make the grade wrestling with latex)
    – Rusi
    Commented Sep 6, 2021 at 1:54
  • I hope the Org mode connection will help it stay put :-)
    – NickD
    Commented Sep 6, 2021 at 1:58
  • Your explanation worked like magic. I can not express enough how grateful I am for such a response, NickD. For your time, for your patience and your willingness to share your knowledge with us. Thank you so much and have a wonderful day!
    – Arvydas
    Commented Sep 6, 2021 at 5:35
  • One more thing: While your answer is pedagogically excellent, it could be made more practically neat (maybe?) by showing how to elide the sty file and inlining it's contents with a #+LATEX: don't you think? (An addition to the answer not a replacement of course)
    – Rusi
    Commented Sep 6, 2021 at 13:48
  • With "normal" LaTeX it might, but when redefining macros, you have to worry about the @ signs which have different category codes when used in a style file. Explaining that would take us too far into the LaTeX weeds I think, hence the blanket recommendation: use a style file when redefining internals.
    – NickD
    Commented Sep 6, 2021 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.