git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: with `--biblatex`, use `\autocite` when possible.

`\autocites{a1}{a2}{a3}` will not collapse the entries. So, if we don't have prefixes and suffixes, we use instead `\autocite{a1;a2;a3}`. Closes #4960.

commita92e43575fb44c47263603b1dc5db9ef4f7421d3 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 8 Oct 2018, 20:47 (8 years ago) parentb60c64d
2 files changed+43−13
src/Text/Pandoc/Writers/LaTeX.hs+21−13 test/command/4960.md+22
src/Text/Pandoc/Writers/LaTeX.hs+21−13
@@ -1366,19 +1366,27 @@ citationsToBiblatex
13661366 AuthorInText -> "textcite"
13671367 NormalCitation -> "autocite"
13681368
1369−citationsToBiblatex (c:cs) = do
1370− args <- mapM convertOne (c:cs)
1371− return $ text cmd <> foldl' (<>) empty args
1372− where
1373− cmd = case citationMode c of
1374− SuppressAuthor -> "\\autocites*"
1375− AuthorInText -> "\\textcites"
1376− NormalCitation -> "\\autocites"
1377− convertOne Citation { citationId = k
1378− , citationPrefix = p
1379− , citationSuffix = s
1380− }
1381− = citeArguments p s k
1369+citationsToBiblatex (c:cs)
1370+ | all (\cit -> null (citationPrefix cit) && null (citationSuffix cit)) (c:cs)
1371+ = do
1372+ let cmd = case citationMode c of
1373+ SuppressAuthor -> "\\autocite*"
1374+ AuthorInText -> "\\textcite"
1375+ NormalCitation -> "\\autocite"
1376+ return $ text cmd <>
1377+ braces (text (intercalate "," (map citationId (c:cs))))
1378+ | otherwise = do
1379+ let cmd = case citationMode c of
1380+ SuppressAuthor -> "\\autocites*"
1381+ AuthorInText -> "\\textcites"
1382+ NormalCitation -> "\\autocites"
1383+ let convertOne Citation { citationId = k
1384+ , citationPrefix = p
1385+ , citationSuffix = s
1386+ }
1387+ = citeArguments p s k
1388+ args <- mapM convertOne (c:cs)
1389+ return $ text cmd <> foldl' (<>) empty args
13821390
13831391citationsToBiblatex _ = return empty
13841392
test/command/4960.mdnew file+22
@@ -0,0 +1,22 @@
1+```
2+% pandoc -t latex --biblatex
3+[@a1;@a2;@a3]
4+^D
5+\autocite{a1,a2,a3}
6+```
7+
8+```
9+% pandoc -t latex --biblatex
10+@a1 [@a2;@a3]
11+^D
12+\textcite{a1,a2,a3}
13+```
14+
15+```
16+% pandoc -t latex --biblatex
17+[@a1, blah; @a2; see @a3]
18+^D
19+\autocites[blah]{a1}{a2}[see][]{a3}
20+```
21+
22+