I'm taking up a long overdue project of converting my service proposals from Word-style to Markdown->TeX, and I'm hitting a kink in producing vertical spacing for signature lines in an output-agnostic fashion.
At the end of my document, I have two signature lines. Markdown makes the workaround of adding empty lines easy:
<!-- sigs.md -->
## Signatures
\
\
___________________________\
Peter Foobar\
*The Foo Company*
\
\
___________________________\
Jon Bar de Foo\
*Bar-Baz Industries*
So two empty lines should appear before the "signature line".
And indeed, it seems that internally, it's well understood:
$ pandoc sigs.md
<!-- sigs.md -->
<h2 id="signatures">Signatures</h2>
<p><br />
<br />
___________________________<br />
Peter Foobar<br />
<em>The Foo Company</em></p>
<p><br />
<br />
___________________________<br />
Jon Bar de Foo<br />
<em>Bar-Baz Industries</em></p>
Two BRs Before the line. So far so good.
However, the LateX writer doesn't seem so nice:
$ pandoc sigs.md -t latex
\subsection{Signatures}\label{signatures}
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\\
Peter Foobar\\
\emph{The Foo Company}
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\\
Jon Bar de Foo\\
\emph{Bar-Baz Industries}
I'm not even sure \\s would work, but I can see they're not there.
Any idea what's wrong?
as a workaround put an escaped space on the line just after your heading:
<!-- sigs.md -->
## Signatures
\ \
\
___________________________\
Peter Foobar\
*The Foo Company*
this should result in
\subsection{Signatures}\label{signatures}
~\\[2\baselineskip]\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\\
Peter Foobar\\
\emph{The Foo Company}
the ~\\[2\baselineskip] is your space(~), then a line break which is two lines tall....
Not sure why this is happening, but I might guess that somehow the affordance of newlines after the heading is affecting the parsing of the hard line breaks that follow...
on second look it is more likely on account of hardline breaks being "inline" so to speak, and so after a block element (heading, paragraph) the parser looks for another block element, and the escaped newline (which is what creates the hard breaks) is ignored. Once we create a single-space-containing paragraph in which to put inline elements like hardline breaks, they are parsed properly.
<!-- sigs.md -->
## Signatures
\ \
\
___________________________\
Peter Foobar\
*The Foo Company*
\ \
\
___________________________\
Jon Bar de Foo\
*Bar-Baz Industries*
\subsection{Signatures}\label{signatures}
~\\[2\baselineskip]\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\\
Peter Foobar\\
\emph{The Foo Company}
~\\[2\baselineskip]\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\\
Jon Bar de Foo\\
\emph{Bar-Baz Industries}
so I have no idea what I'm talking about...this is clearly not a parser problem as the AST and JSON output look fine:
Here's the JSON representation of original "sigs.md" from above:
{
"blocks": [
{ "t": "RawBlock",
"c": [ "html", "<!-- sigs.md -->" ]
}, {
"t": "Header",
"c": [2, ["signatures", [], [] ], [{"t": "Str", "c": "Signatures"}]]
}, {
"t": "Para",
"c": [
{"t": "LineBreak"},
{"t": "LineBreak"},
{"t": "Str", "c": "___________________________"},
{"t": "LineBreak"},
{"t": "Str", "c": "Peter"},
{"t": "Space"},
{"t": "Str", "c": "Foobar"},
{"t": "LineBreak"},
{"t": "Emph", "c": [{"t": "Str", "c": "The"}, {"t": "Space"}, {"t": "Str", ...
As @joallard said originally, this is likely something to do with the LaTeX writer. More specifically it seems the LaTeX writer is not properly handling paragraphs that start off with line breaks....
This explains it (from LaTeX writer):
blockToLaTeX (Para lst) =
inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
Why do we do this? Well, I think it was because naively
rendering line breaks at the beginning of a LaTeX paragraph
causes errors. Maybe there's a better way to handle it.
So it seems linebreaks in LaTeX need a line to break, otherwise they throw an error. One solution would be to use \hfill\break for each linebreak that starts a paragraph.
For simplicity in the writer, every linebreak could in fact just be rendered as \hfill\break if this was easier. Or, some combination of \hfills, \breaks, \\s, and \baselineskips could be used.
Most helpful comment
This explains it (from LaTeX writer):
Why do we do this? Well, I think it was because naively
rendering line breaks at the beginning of a LaTeX paragraph
causes errors. Maybe there's a better way to handle it.