-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
In latex output, pandoc does not put a comment character after \CSLLeftMargin{ ... }
, which results in \CSLLeftMargin{ ... }
and \CSLRightInline{ ... }
effectively being separated by a space char.
Since the widths of \CSLLeftMargin
and \CSLRightInline
are defined as \csllabelwidth
and \linewidth - \csllabelwidth
, their combined width including the separating space amounts to \linewidth
plus the width of a space char, resulting in a line wider than \linewidth
.
Running pandoc -s -C test.md -o test.pdf
does place the \CSLLeftMargin
and \CSLRightInline
boxes on the same horizontal position in the pdf, but the \CSLRightInline
box extends into the right margin (and pandoc -s -C test.md -o intermediate_tex_file.tex
followed by pdflatex intermediate_tex_file.tex
shows that pdflatex complains about Overfull \hbox (2.22221pt too wide) in paragraph at lines 85--91
).
In beamer output (pandoc -s -C test.md -t beamer -o test.pdf
), the effect is more drastic: Here, the \CSLLeftMargin
and \CSLRightInline
boxes appear on different lines, as shown below:
Expected layout:
Suggested solution: Either add a comment character after \CSLLeftMargin{ ... }
to prevent a space from appearing between the \CSLLeftMargin
and \CSLRightInline
boxes, or reduce the \CSLRightInline
width by modifying the definition to something like
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth - \fontdimen2\font}{#1}\break}
(The simplest method for specifying the width of the space char of the active font seems to be to use \fontdimen2\font
; see https://tex.stackexchange.com/questions/30746/how-does-tex-know-how-to-space-different-typefaces and https://tex.stackexchange.com/questions/390651/how-to-calculate-the-width-of-a-space.)
Or use explicit widths, defining
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth - 1ex}{#1}\break}
and outputting
\CSLLeftMargin{ ... }\hspace{1ex}%
\CSLRightInline{ ... }
test.md
(with examples for two LeftMargin/RightInline CSL styles, and not using section headers to keep all text on one beamer slide):
---
csl: nature.csl
# csl: vancouver.csl
references:
- id: olson:2006codes
author:
- family: Olson
given: Hope A.
container-title: Library Quarterly
DOI: 10.1086/504343
issue: '1'
issued: 2006
language: en-US
page: 19-35
title: 'Codes, costs, and critiques: The organization of information in *Library
Quarterly*, 1931–2004'
type: article-journal
volume: '76'
...
Blah [@olson:2006codes]. Blah blah. And some more text just to show the width of a normal paragraph.
References
pandoc 2.17.0.1 / macOS 11.6.2