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.
This commit is contained in:
John MacFarlane 2018-10-08 20:47:09 -07:00
parent b60c64d06e
commit a92e43575f
2 changed files with 43 additions and 13 deletions

View file

@ -1366,19 +1366,27 @@ citationsToBiblatex
AuthorInText -> "textcite"
NormalCitation -> "autocite"
citationsToBiblatex (c:cs) = do
args <- mapM convertOne (c:cs)
return $ text cmd <> foldl' (<>) empty args
where
cmd = case citationMode c of
SuppressAuthor -> "\\autocites*"
AuthorInText -> "\\textcites"
NormalCitation -> "\\autocites"
convertOne Citation { citationId = k
, citationPrefix = p
, citationSuffix = s
}
= citeArguments p s k
citationsToBiblatex (c:cs)
| all (\cit -> null (citationPrefix cit) && null (citationSuffix cit)) (c:cs)
= do
let cmd = case citationMode c of
SuppressAuthor -> "\\autocite*"
AuthorInText -> "\\textcite"
NormalCitation -> "\\autocite"
return $ text cmd <>
braces (text (intercalate "," (map citationId (c:cs))))
| otherwise = do
let cmd = case citationMode c of
SuppressAuthor -> "\\autocites*"
AuthorInText -> "\\textcites"
NormalCitation -> "\\autocites"
let convertOne Citation { citationId = k
, citationPrefix = p
, citationSuffix = s
}
= citeArguments p s k
args <- mapM convertOne (c:cs)
return $ text cmd <> foldl' (<>) empty args
citationsToBiblatex _ = return empty

22
test/command/4960.md Normal file
View file

@ -0,0 +1,22 @@
```
% pandoc -t latex --biblatex
[@a1;@a2;@a3]
^D
\autocite{a1,a2,a3}
```
```
% pandoc -t latex --biblatex
@a1 [@a2;@a3]
^D
\textcite{a1,a2,a3}
```
```
% pandoc -t latex --biblatex
[@a1, blah; @a2; see @a3]
^D
\autocites[blah]{a1}{a2}[see][]{a3}
```