Skip to content

Commit

Permalink
Implement \DeclareCitePunctuationPosition (plk#733)
Browse files Browse the repository at this point in the history
Similar to \DeclareAutoCiteCommand's optional position argument.
  • Loading branch information
moewew committed Oct 15, 2018
1 parent 2cc0171 commit 2a8fc16
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 8 deletions.
3 changes: 3 additions & 0 deletions doc/latex/biblatex/CHANGES.md
Expand Up @@ -97,6 +97,9 @@
```
\newrobustcmd*{\enquote}{\mkbibquote}
```
- `\DeclareCitePunctuationPosition` can be used to configure the punctuation
position for citation commands similar to the optional `position` argument
of `\DeclareAutoCiteCommand`.

# RELEASE NOTES FOR VERSION 3.11
- `\printbiblist` now supports `driver` and `biblistfilter` options
Expand Down
15 changes: 15 additions & 0 deletions doc/latex/biblatex/biblatex.tex
Expand Up @@ -6983,6 +6983,20 @@ \subsubsection{Citation Style Files}
\ExecuteBibliographyOptions{autocite=<<name>>}
\end{ltxexample}

\cmditem{DeclareCitePunctuationPosition}{command}{position}

Set up the cite command \prm{command} to move punctuation marks after the citation like \cmd{autocite}. The \prm{position} argument can take the values \opt{r}, \opt{l}, \opt{f}, \opt{c}, \opt{o} and \opt{d}.
If an unknown \prm{position} identifier is used, it defaults to \opt{o}.
\begin{valuelist}
\item[r] The punctuation mark is not moved and remains to the right of the citation.
\item[l] The punctuation mark is moved to the left of the citation and thus appears before it.
\item[f] Like \opt{r} in footnotes and like \opt{l} otherwise.
\item[c] Pass the punctuation on to the internal implementation of the citation commands. It will then be executed within the \prm{wrapper} command if given.
\item[o] Retain the default set-up of \opt{c} for citation defined commands without \prm{wrapper} command and \opt{l} for citation commands defined with a \prm{wrapper} command.
\item[d] Drop the explicit punctuation mark. It will only be available as the field \bibfield{postpunct}.
\end{valuelist}
%
This command can not be used for \cmd{autocite}, to configure \cmd{autocite} use the optional \prm{position} argument for \cmd{DeclareAutoCiteCommand}.
\end{ltxsyntax}

\subsubsection{Special Fields}
Expand Down Expand Up @@ -13482,6 +13496,7 @@ \section{Revision History}
\item Added \cs{ifdateyearsequal}\see{aut:aux:tst}
\item Added <and higher> sectioning values for \opt{citereset}, \opt{refsection} and \opt{refsegment} options\see{use:opt:pre:gen}
\item Added Hungarian localisation\see{use:loc:hun}
\item Added \cmd{DeclareCitePunctuationPosition}\see{aut:cbx:cbx}
\end{release}

\begin{release}{3.11}{2018-02-20}
Expand Down
80 changes: 72 additions & 8 deletions tex/latex/biblatex/biblatex.sty
Expand Up @@ -10883,18 +10883,52 @@
{\blx@defcitecmd@ii{#2#1}}}
\long\def\blx@defcitecmd@ii#1{%
\protected\csedef{blx@cite@#1}{\blxciteicmd{#1}}%
\blx@defcitecmd@iv{#1}}
\csundef{blx@defcite@wrapper@#1}%
\blx@defcitecmd@iv{#1}%
\blx@defcitecmd@v{#1}}
\long\def\blx@defcitecmd@iii#1[#2]{%
\csdef{blx@defcite@wrapper@#1}{#2}%
\blx@defcitecmd@iv{#1}%
\blx@defcitecmd@v{#1}}
\long\def\blx@defcitecmd@iv#1{%
\protected\long\csedef{blx@cite@#1}##1##2##3##4{%
\begingroup
\blx@citeinit
\unexpanded{#2}{\blxciteicmd{#1}{##1}{##2}{##3}{}}%
##4\endgroup}%
\blx@defcitecmd@iv{#1}}
\ifboolexpe{test {\ifcsundef{blx@defcite@wrapper@#1}}
and
(test {\ifcsundef{blx@citepunct@#1}}
or
test {\ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}})}
{}
{\begingroup
\blx@citeinit}%
\ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@l}
{\noexpand\unspace##4}
{}%
\ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@f}
{\noexpand\iftoggle{blx@footnote}{}{\unspace##4}}
{}%
\ifcsundef{blx@defcite@wrapper@#1}
{\blxciteicmd{#1}{##1}{##2}{##3}{%
\ifcsundef{blx@citepunct@#1}{##4}{}%
\ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}{##4}{}}}
{\csexpandonce{blx@defcite@wrapper@#1}{%
\blxciteicmd{#1}{##1}{##2}{##3}{%
\ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}{##4}{}}}%
\ifcsundef{blx@citepunct@#1}{##4}{}}%
\ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@r}{##4}{}%
\ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@f}
{\noexpand\iftoggle{blx@footnote}{##4}{}}
{}%
\ifboolexpe{test {\ifcsundef{blx@defcite@wrapper@#1}}
and
(test {\ifcsundef{blx@citepunct@#1}}
or
test {\ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}})}
{}
{\endgroup}}}
\long\def\blx@defcitecmd@iv#1#2#3#4#5{%
\long\def\blx@defcitecmd@v#1#2#3#4#5{%
\protected\long\csdef{blx@citei@#1}##1##2##3##4{%
\ifblank{##1}
{}
Expand Down Expand Up @@ -11140,6 +11174,36 @@
{\let\blx@thecheckpunct\blx@checkpunct
\def\blx@autopunct{#1}}}
% {<command>}{<pos marker>}
% pos markers are:
% l: move punctuation before the command (i.e. left of it)
% r: leave punctuation after the command (i.e. to the right)
% f: like l in normal text, like r in footnotes
% c: pass on to the cite command,
% the punctuation will eventually end up as field 'postpunct'
% d: discard the punctuation
% o (or any other value): restores the old standard behaviour
% r for wrapped citation commands,
% c for unwrapped ones
\newrobustcmd*{\DeclareCitePunctuationPosition}[2]{%
\begingroup
\escapechar\m@ne
\edef\blx@tempa{\endgroup
\noexpand\blx@defcitepunctpos@i{\string#1}{#2}}%
\blx@tempa}
\def\blx@citepunctid@pos@l{l}
\def\blx@citepunctid@pos@r{r}
\def\blx@citepunctid@pos@f{f}
\def\blx@citepunctid@pos@c{c}
\def\blx@citepunctid@pos@d{d}
\def\blx@defcitepunctpos@i#1#2{%
\ifcsundef{blx@citepunctid@pos@#2}
{\csundef{blx@citepunct@#1}}
{\csletcs{blx@citepunct@#1}{blx@citepunctid@pos@#2}}%
\blx@defcitecmd@iv{#1}}
\AfterEndPreamble{% babel
\begingroup
\makeatletter
Expand Down

0 comments on commit 2a8fc16

Please sign in to comment.