Discussion:
Linebreaks in LaTeX output after "Header 4" and "Header 5"
Kolbe Kegel
2015-02-05 20:03:02 UTC
Permalink
Hi,

I'm converting from Markdown to PDF. This so far has been going really
well, but I ran into an issue where "Header 4" (#### in markdown) and
"Header 5" (##### in markdown) are translated, respectively,
into \paragraph and \subparagraph in LaTeX. Apparently LaTeX doesn't put a
linebreak after \paragraph and \subparagrph. The result is that the text in
Header 4 and Header 5 flows directly into the follow body.

I want to somehow have pandoc automatically add linebreaks after these
\paragraph and \subparagraph LaTeX commands. Is that feasible? Is there a
better solution?

For example:

<document>
# Header 1
## Header 2
### Header 3
This is the body of Header 3.

#### Header 4
This is the body of Header 4.

##### Header 5
This is the body of Header 5.
</document>

is rendered this way (copied/pasted from this PDF: http://uy.pe/f/test.pdf):

<output>
Header 1
Header 2
Header 3
This is the body of Header 3.
Header 4 This is the body of Header 4.
Header 5 This is the body of Header 5.
</output>

I am not really bothered by the fact that the font sizes of the "Header 4"
and "Header 5" output are indistinguishable from the font used for the
body. I'm only worried about the lack of linebreaks.

Any help or guidance would be much appreciated!

Kolbe
--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+***@googlegroups.com.
To post to this group, send email to pandoc-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/b4244cdf-5931-4bef-9318-323e0563bb94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Raniere Silva
2015-02-05 20:45:27 UTC
Permalink
Hi Kolbe,
Post by Kolbe Kegel
I want to somehow have pandoc automatically add linebreaks after these
\paragraph and \subparagraph LaTeX commands. Is that feasible? Is there a
better solution?
This is more a LaTeX problem. Searching (La)TeX Exchange I found
http://tex.stackexchange.com/a/67349
and http://tex.stackexchange.com/a/5040.

I would try using a custom template.

1. Download
https://raw.githubusercontent.com/jgm/pandoc-templates/master/default.latex
as `custom.latex` at the same folder of the document you want to convert.
2. Change it based on (La)TeX Exchange replies.
3. Convert your document with

$ pandoc -f markdown -t latex --template=custom -o test.tex test.md
4. Compile test.tex

Hope this help.

Cheers,
Raniere
--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+***@googlegroups.com.
To post to this group, send email to pandoc-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20150205204527.GH7841%40pupunha.tsa.virtua.com.br.
For more options, visit https://groups.google.com/d/optout.
Kolbe Kegel
2015-02-05 21:14:47 UTC
Permalink
Hi Raniere!
Post by Raniere Silva
Hi Kolbe,
Post by Kolbe Kegel
I want to somehow have pandoc automatically add linebreaks after these
\paragraph and \subparagraph LaTeX commands. Is that feasible? Is there a
better solution?
This is more a LaTeX problem. Searching (La)TeX Exchange I found
http://tex.stackexchange.com/a/67349
and http://tex.stackexchange.com/a/5040.
I would try using a custom template.
1. Download
https://raw.githubusercontent.com/jgm/pandoc-templates/master/default.latex
as `custom.latex` at the same folder of the document you want to convert.
2. Change it based on (La)TeX Exchange replies.
3. Convert your document with
$ pandoc -f markdown -t latex --template=custom -o test.tex test.md
4. Compile test.tex
Great sleuthing, thanks so much. It looks like this did the trick:

--- default.latex 2015-02-05 13:13:32.000000000 -0800
+++ custom.latex 2015-02-05 13:12:37.000000000 -0800
@@ -143,6 +143,14 @@
$header-includes$
$endfor$

+
+\usepackage[raggedright]{titlesec}
+\titleformat{\paragraph}[hang]{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
+\titlespacing*{\paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{0.5em}
+
+\titleformat{\subparagraph}[hang]{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
+\titlespacing*{\subparagraph}{0pt}{3.25ex plus 1ex minus .2ex}{0.5em}
+
\begin{document}
$if(title)$
\maketitle
--
Kolbe Kegel, Principal Support Engineer
MariaDB Corporation | http://www.mariadb.com
--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+***@googlegroups.com.
To post to this group, send email to pandoc-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/E3A16DCA-A570-403E-A1DA-1E14F6333CA4%40mariadb.com.
For more options, visit https://groups.google.com/d/optout.
Loading...