Skip to content

Commit

Permalink
Rewrite CSLReferences environment...
Browse files Browse the repository at this point in the history
...to avoid depending on enumitem, which plays badly with
beamer.  Instead we use a regular list environment.
Thanks to @jpcirrus for the concept.

We also restore the pre-3.1.7 format of the CSLReferences
environment, which again has two parameters. The first
determines whether a hanging indent is used (1 = yes, 0 = no),
and the second is the entry line spacing (0 = none).

Closes #9053.
  • Loading branch information
jgm committed Sep 6, 2023
1 parent 4b1fc4d commit b7e1ce4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
22 changes: 13 additions & 9 deletions data/templates/default.latex
Original file line number Diff line number Diff line change
Expand Up @@ -350,15 +350,19 @@ $if(csl-refs)$
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newlength{\cslentryspacing}
\setlength{\cslentryspacing}{0em}
\usepackage{enumitem}
\newlist{CSLReferences}{itemize}{1}
\setlist[CSLReferences]{label={},
leftmargin=\cslhangindent,
itemindent=-1\cslhangindent,
parsep=\parskip,
itemsep=\cslentryspacing}
\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
{\begin{list}{}{%
\setlength{\itemindent}{0pt}
\setlength{\leftmargin}{0pt}
\setlength{\parsep}{0pt}
% turn on hanging indent if param 1 is 1
\ifodd #1
\setlength{\leftmargin}{\cslhangindent}
\setlength{\itemindent}{-1\cslhangindent}
\fi
% set entry spacing
\setlength{\itemsep}{#2\baselineskip}}}
{\end{list}}
\usepackage{calc}
\newcommand{\CSLBlock}[1]{\hfill\break#1\hfill\break}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
Expand Down
15 changes: 8 additions & 7 deletions src/Text/Pandoc/Writers/LaTeX.hs
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,15 @@ blockToLaTeX (Div (identifier,classes,kvs) bs) = do
then do
modify $ \st -> st{ stHasCslRefs = True }
inner <- blockListToLaTeX bs
return $ (if "hanging-indent" `notElem` classes
then "\\setlength{\\cslhangindent}{0em}"
else mempty)
$$ ("\\setlength{\\cslentryspacing}" <> braces
return $ ("\\begin{CSLReferences}"
<> braces
(if "hanging-indent" `elem` classes
then "1"
else "0")
<> braces
(case lookup "entry-spacing" kvs of
Nothing -> "0em"
Just s -> (literal s <> "\\baselineskip")))
$$ "\\begin{CSLReferences}"
Nothing -> "0"
Just s -> literal s))
$$ inner
$+$ "\\end{CSLReferences}"
else blockListToLaTeX bs
Expand Down

0 comments on commit b7e1ce4

Please sign in to comment.