From 9557eb6f8efafaff2e3a61e43e4cc7e4717ad9eb Mon Sep 17 00:00:00 2001 From: Jose Luis Duran Date: Wed, 27 Aug 2014 20:35:57 +0000 Subject: LaTeX writer: Use a declaration for tight lists Currently, pandoc has hard-coded the following in order to make tight lists in LaTeX: ```hs text "\\itemsep1pt\\parskip0pt\\parsep0pt" ``` Which is fine, but does not allow customizations. For example, the `memoir` class already has a `\tightlist` declaration for this purpose: ```tex \newcommand{\tightlist}{% \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} ``` I'm proposing to use a similar solution: ```diff @@ In Writers/LaTeX.hs: -then text "\\itemsep1pt\\parskip0pt\\parsep0pt" +then text "\\tightlist" @@ In templates/default.latex: +\newcommand{\tightlist}{% + \setlength{\itemsep}{1pt}\setlength{\parskip}{0pt}\setlength{\parsep}{0pt}} ``` This allows us to customize the tightness to our needs. Backward Compatibility If a person is using a custom LaTeX template (not based upon the `memoir` class), the `\tightlist` declaration must be added. --- src/Text/Pandoc/Writers/LaTeX.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 8e3befe19..0fa1e4857 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -411,7 +411,7 @@ blockToLaTeX (BulletList lst) = do let inc = if incremental then "[<+->]" else "" items <- mapM listItemToLaTeX lst let spacing = if isTightList lst - then text "\\itemsep1pt\\parskip0pt\\parsep0pt" + then text "\\tightlist" else empty return $ text ("\\begin{itemize}" ++ inc) $$ spacing $$ vcat items $$ "\\end{itemize}" @@ -446,7 +446,7 @@ blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do else "\\setcounter" <> braces enum <> braces (text $ show $ start - 1) let spacing = if isTightList lst - then text "\\itemsep1pt\\parskip0pt\\parsep0pt" + then text "\\tightlist" else empty return $ text ("\\begin{enumerate}" ++ inc) $$ stylecommand @@ -460,7 +460,7 @@ blockToLaTeX (DefinitionList lst) = do let inc = if incremental then "[<+->]" else "" items <- mapM defListItemToLaTeX lst let spacing = if all isTightList (map snd lst) - then text "\\itemsep1pt\\parskip0pt\\parsep0pt" + then text "\\tightlist" else empty return $ text ("\\begin{description}" ++ inc) $$ spacing $$ vcat items $$ "\\end{description}" -- cgit v1.2.3