0

I am trying to convert markdown headers to latex without them being caught by a ToC. So in other words, in markdown I would do like this:


 - # header 1
 - ## header 2
 - ### header 3
 - #### header 4
 - ##### header 5
 - ###### header 6

My markdown processor would show it like:

header 1

header 2

Header 3

header 4

header 5
header 6

When I try something similar with latex, it always seems to give it numbers on the first 4 levels. I do not want that while in a list (only when used as real headers like chapter, section etc).

\begin{itemize}
\item \chapter{header 1}
\item \section{header 2}
\item \subsection{Header 3}
\item \subsubsection{header 4}
\item \paragraph{header 5}
\item \#\#\#\#\#\# header 6
\end{itemize}

Several issue I am encountering with this approach.

First the numbers 2, 2.1 and 2.1.1 are added Secondly, in overleaf it starts the list almost on the top of the page with an empty list item, then on the next page it starts with header 1, header 2 (not itemized), header 3 (itemized), header 4 and 5 (not itemized) and lastly header 6 (itemized). Lastly, is there an equivalent for header 6 in latex???

More importantly, how do I get it similar as my markdown processor?

1 Answer 1

1

Of course, without using starting hyphens as this make a list and section headers have no any sense inside a list.

In the example below you can see how to show (or not) the existence of a ToC, the depth of the levels showed in ToC, how to number sections (or not), and how to disable numeration but not the ToC for specific sections when number_sections: yes in the header (header 2 and 3 in the example). Play to change every option (yes to no, 3 to 0, etc.) to realize of the effects.

---
output: 
  pdf_document: 
    toc: yes
    toc_depth: 3
    number_sections: no
---

# header 1

## header 2 {-}

### header 3 {.unnumbered}

#### header 4 

##### header 5

###### header 6

As it is now, the result should be:

enter image description here

Note that the header six is not in bold and do not start a new line as you showed. This is not for any wrong in the Markdown and if is only because this is the default format, in LaTeX default document class. If you really need the 6th level (usually is not a good idea to use more than 3-4 levels), you should use also custom template or include a LaTeX preamble to redefine the default style. In any case, this should not change the syntax of the Markdown text.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .