Skip to content

Commit

Permalink
Introduce option to automatically use sequens, sequentes in postnote (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jspitz authored Nov 13, 2024
1 parent e4fd759 commit 4c9a2a8
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 4 deletions.
9 changes: 9 additions & 0 deletions doc/latex/biblatex/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# RELEASE NOTES FOR VERSION 3.21
- Added `\mkseqrange` and `\mkseqrange*` to format pages in citations
using the bibstrings `sequens` and `sequentes` if applicable.
- Added new option `citepagerange` to customize the format of page ranges.
- Added `\mkautorange` and `\mkautorange*` which forward to `\mknormrange`,
`\mkcomprange` or `\mkseqrange` (or their starred counterpart, respectively)
depending on the `citepagerange` value.
- Use `\mkautorange` in standard styles.

# RELEASE NOTES FOR VERSION 3.20
- Added new option settings `minyearinit` and `minyearfull` for
`uniquename`
Expand Down
54 changes: 52 additions & 2 deletions doc/latex/biblatex/biblatex.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2354,6 +2354,22 @@ \subsubsection{Preamble Options}

This feature requires support by the selected citation style. All standard styles which come with this package support indexing of both citations and entries in the bibliography. Note that you still need to enable indexing globally with \cmd{makeindex} to get an index.

\optitem[normalized]{citepagerange}{\opt{normalized}, \opt{2sq}, \opt{3sqq}, \opt{allsqq}, \opt{compressed}}

This option controls how page ranges are formatted in the postnote field of citations. The following formats are available:

\begin{valuelist}
\item[normalized] The cited pages are output with normalized ranges and full starting and ending pages in all cases, \eg the list <1-2, 11-13, 21-24> is output as <1--2, 11--13, 21--24>.
\item[2sq] A range of exactly two consecutive pages is printed using the starting page and the localisation string \texttt{sequens}, \eg the above list is compressed to <1\,sq., 11--13, 21--24>.
\item[3sqq] Similar in concept to \opt{2sq} but, additionally, a range of exactly three consecutive pages is printed using the starting page and the localisation string \texttt{sequentes}, \eg the above list is compressed to <1\,sq., 11\,sqq., 21--24>.
\item[allsqq] Similar in concept to \opt{3sqq} with the difference that \texttt{sequentes} is defined as <any range of more than two consecutive pages>. Hence, the above list is compressed to <1\,sq., 11\,sqq., 21\,sqq.>.
\item[compressed] The page ranges are compressed with \cmd{mkcomprange} (see \secref{aut:aux:msc}), so the above list comes out as <1--2, 11--3, 21--4>.
\end{valuelist}

The spacing inserted between the page number and the respective localisation string may be modified by redefining the macro \cmd{sqspace}.

Note that this feature is only supported by citation styles that use \cmd{mkautorange} or \cmd{mkautorange*} for formatting page ranges in the postscript field (see \secref{aut:aux:msc}). When using \cmd{mkseqrange} or \cmd{mkseqrange*}, \opt{2sq}, \opt{3ssq}, and \opt{allsqq} are considered, any other value equals \opt{3ssq}.

\boolitem[false]{loadfiles}

This option controls whether external files requested by way of the \cmd{printfile} command are loaded. See also \secref{use:use:prf} and \cmd{printfile} in \secref{aut:bib:dat}. Note that this feature is disabled by default for performance reasons.
Expand Down Expand Up @@ -4889,9 +4905,13 @@ \subsubsection{Miscellaneous Commands}

In the \prm{postnote} argument to a citation command, this command indicates a range of two pages where only the starting page is given. See \secref{use:cav:pag} for further details and usage instructions. The suffix printed is the localisation string \texttt{sequens}, see \secref{aut:lng:key}. The spacing inserted between the suffix and the page number may be modified by redefining the macro \cmd{sqspace}. The default is an unbreakable interword space. Note that this command is only available locally in citations and the bibliography.

Note also that you might want to use the option \opt{citepagerange} (see \secref{use:opt:pre:gen}) to automatize the use of this command rather than entering it manually.

\csitem{psqq}

Similar to \cmd{psq} but indicates an open-ended page range. See \secref{use:cav:pag} for further details and usage instructions. The suffix printed is the localisation string \texttt{sequentes}, see \secref{aut:lng:key}. This command is only available locally in citations and the bibliography.
Similar to \cmd{psq} but, depending on the convention, indicates either a range of three pages or an open-ended page range greater than two pages. See \secref{use:cav:pag} for further details and usage instructions. The suffix printed is the localisation string \texttt{sequentes}, see \secref{aut:lng:key}. This command is only available locally in citations and the bibliography.

Note also that you might want to use the option \opt{citepagerange} (see \secref{use:opt:pre:gen}) to automatize the use of this command rather than entering it manually.

\cmditem{pnfmt}{text}

Expand Down Expand Up @@ -11248,6 +11268,30 @@ \subsubsection{Miscellaneous Commands}

This command, which is intended for use in field formatting directives, will parse its \prm{text} argument for page ranges and will normalise them. The command is similar to \cmd{mkcomprange} except that the page ranges will not be compressed. The scanner recognises \cmd{bibrangedash} and hyphens as range dashes. It will normalize the dash by replacing any number of consecutive hyphens with \cmd{bibrangedash}. Lists of ranges delimited with \cmd{bibrangessep} are also supported. The scanner will normalise any comma or semicolons surrounded by optional space by replacing them with \cmd{bibrangessep}. If you want to hide a character from the list/range scanner for some reason, wrap the character or the entire string in curly braces. The optional \prm{postpro} argument specifies a macro to be used for post-processing the \prm{text}. See \cmd{mkcomprange} on how to use this argument. The starred version of this command differs from the regular one in the way the \prm{postpro} argument is applied to a list of values. The second optional argument \prm{itempostpro} is used to post-process each individual number item in the formatted list. It can be used to convert numbers from cardinals to ordinals. If only one optional argument is present, it is treated as \prm{postpro}.

\cmditem{mkseqrange}[postpro][itempostpro]{text}
\cmditem*{mkseqrange*}[postpro][itempostpro]{text}

This command, which is intended for use in field formatting directives, will parse its \prm{text} argument for page ranges and will normalise them similar to \cmd{mknormrange}. The difference is that the command will output only the first page and the localisation string \texttt{sequens} or \texttt{sequentes}, respectively, if applicable (depending on the setting of the \opt{citepagerange} option; see \secref{use:opt:pre:gen}). The scanner recognises \cmd{bibrangedash} and hyphens as range dashes. It will normalize the dash by replacing any number of consecutive hyphens with \cmd{bibrangedash}. Lists of ranges delimited with \cmd{bibrangessep} are also supported. The scanner will normalise any comma or semicolons surrounded by optional space by replacing them with \cmd{bibrangessep}. If you want to hide a character from the list/range scanner for some reason, wrap the character or the entire string in curly braces. The optional \prm{postpro} argument specifies a macro to be used for post-processing the \prm{text}. See \cmd{mkcomprange} on how to use this argument. The starred version of this command differs from the regular one in the way the \prm{postpro} argument is applied to a list of values. The second optional argument \prm{itempostpro} is used to post-process each individual number item in the formatted list. It can be used to convert numbers from cardinals to ordinals. If only one optional argument is present, it is treated as \prm{postpro}. For example, with default \opt{citepagerange} settings:

\begin{ltxexample}
\mkseqrange[\mkpageprefix]{5, 123-124, 423-439, 522-524}
\mkseqrange*[\mkpageprefix]{5, 123-124, 423-439, 522-524}
\end{ltxexample}
%
will output:

\begin{ltxexample}
pp. 5, 123 sq., 423-439, 522 sqq.
p. 5, pp. 123 sq., pp. 423-439, pp. 522 sqq.
\end{ltxexample}

\cmditem{mkautorange}[postpro][itempostpro]{text}
\cmditem*{mkautorange*}[postpro][itempostpro]{text}

This command, which is intended for use in field formatting directives, is a portmanteau command which is equal to \cmd{mkseqrange} or \cmd{mkseqrange*}, respectively, if the \opt{citepagerange} option (see \secref{use:opt:pre:gen}) is set to \opt{2sq}, \opt{3sqq}, or \opt{allsqq}, to \cmd{mkcomprange} or \cmd{mkcomprange*}, respectively, if the \opt{citepagerange} option is set to \opt{compressed}, and to \cmd{mknormrange} or \cmd{mknormrange*} with \opt{normalized} and by default.
Use this if you want to give the users of your style the choice to toggle \opt{citepagerange}.


\cmditem{mkfirstpage}[postpro][itempostpro]{text}
\cmditem*{mkfirstpage*}[postpro][itempostpro]{text}

Expand Down Expand Up @@ -12367,7 +12411,7 @@ \subsubsection{Localization Keys}
\item[loccit] The term equivalent to the Latin term <loco citato> (<[at] the place [already] cited>).
\item[confer] The term equivalent to the Latin <confer> (<compare>).
\item[sequens] The term equivalent to the Latin <sequens> (<[and] the following [page]>), as used to indicate a range of two pages when only the starting page is provided (\eg\ <25\,sq.> or <25\,f.> instead of <25--26>).
\item[sequentes] The term equivalent to the Latin <sequentes> (<[and] the following [pages]>), as used to indicate an open"=ended range of pages when only the starting page is provided (\eg\ <25\,sqq.> or <25\,ff.>).
\item[sequentes] The term equivalent to the Latin <sequentes> (<[and] the following [pages]>), as used to indicate, depending on convention, either a range of exactly three pages or an open"=ended range of pages (\textgreater 2) when only the starting page is provided (\eg\ <25\,sqq.> or <25\,ff.>).
\item[passim] The term equivalent to the Latin <passim> (<throughout>, <here and there>, <scatteredly>).
\end{keymarglist}
%
Expand Down Expand Up @@ -15032,6 +15076,12 @@ \section{Revision History}
This revision history is a list of changes relevant to users of this package. Changes of a more technical nature which do not affect the user interface or the behavior of the package are not included in the list. More technical details are to be found in the \file{CHANGES.md} file. The numbers on the right indicate the relevant section of this manual.

\begin{changelog}
\begin{release}{3.21}{2024-}
\item Added \cmd{mkseqrange} and \cmd{mkseqrange*} to format pages in citations using the bibliography strings \texttt{sequens} and \texttt{sequentes} if applicable\see{aut:aux:msc}
\item Added option \opt{citepagerange} to customize the format of page ranges\see{use:opt:pre:gen}
\item Added \cmd{mkautorange} and \cmd{mkautorange*} which forwards to \cmd{mknormrange}, \cmd{mkcomprange} or \cmd{mkseqrange} (or their starred counterpart, respectively) depending on the \opt{citepagerange} value\see{aut:aux:msc}
\item Use \cmd{mkautorange} in standard styles.
\end{release}
\begin{release}{3.20}{2024-03-22}
\item Added new \opt{uniquename} options \see{use:opt:pre:int}
\item Added default full date sorting templates\see{use:opt:pre}
Expand Down
4 changes: 2 additions & 2 deletions tex/latex/biblatex/biblatex.def
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,9 @@
\ifcapital{\MakeCapital{#1}}{#1}\isdot}
% citation commands
\DeclareFieldFormat{prenote}{#1\isdot}
\DeclareFieldFormat{postnote}{\mkpageprefix[pagination][\mknormrange]{#1}}
\DeclareFieldFormat{postnote}{\mkpageprefix[pagination][\mkautorange]{#1}}
\DeclareFieldFormat{volcitevolume}{\bibstring{volume}\ppspace#1}
\DeclareFieldFormat{volcitepages}{\mkpageprefix[pagination][\mknormrange]{#1}}
\DeclareFieldFormat{volcitepages}{\mkpageprefix[pagination][\mkautorange]{#1}}
\DeclareFieldFormat{volcitenote}{\mkvolcitenote#1}
\newrobustcmd*{\mkvolcitenote}[2]{%
\printtext[volcitevolume]{#1}%
Expand Down
137 changes: 137 additions & 0 deletions tex/latex/biblatex/biblatex.sty
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,10 @@
\newtoggle{blx@noroman}
\newtoggle{blx@nohashothers}
\newtoggle{blx@nosortothers}
\newtoggle{blx@pagecomp}
\newtoggle{blx@pagesq}
\newtoggle{blx@allpagesq}
\newtoggle{blx@twopagesq}
\newtoggle{blx@singletitle}
\newtoggle{blx@uniquebaretitle}
\newtoggle{blx@uniqueprimaryauthor}
Expand Down Expand Up @@ -3740,6 +3744,118 @@
\expandafter\blx@comprange@end
\fi}

% <*>[<postpro>]{<string>}
\newrobustcmd*{\mkseqrange}{%
\begingroup
\@ifstar
{\blx@range@aux\blx@seqrange@ii}
{\blx@range@aux\blx@seqrange@i}}

\def\blx@seqrange@i[#1][#2]#3{%
\let\blx@tempa\@empty
\protected\def\blx@range@out@value{\appto\blx@tempa}%
\def\blx@range@out@item@process{#2}%
\let\blx@range@out@delim\blx@range@out@value
\let\blx@range@split\blx@genrange@split
\let\blx@range@process\blx@seqrange@check
\blx@range@chunk{#3}%
\begingroup
\edef\blx@tempa{\endgroup
\unexpanded{#1}{\expandonce\blx@tempa}}%
\blx@tempa
\endgroup}

\def\blx@seqrange@ii[#1][#2]#3{%
\protected\def\blx@range@out@value{#1}%
\def\blx@range@out@item@process{#2}%
\let\blx@range@out@delim\@firstofone
\let\blx@range@split\blx@genrange@split
\let\blx@range@process\blx@seqrange@check
\blx@range@chunk{#3}%
\endgroup}

\def\blx@seqrange@check#1#2{%
\blx@imc@ifinteger{#1}
{\blx@imc@ifinteger{#2}
{\@firstoftwo}
{\@secondoftwo}}
{\@secondoftwo}
{\blx@seqrange@comp{#1}{#2}}
{\begingroup
\protected@edef\blx@tempc{\endgroup
\blx@range@out@value{%
\blx@range@out@item@process{\unexpanded{#1}}%
\noexpand\bibrangedash
\blx@range@out@item@process{\unexpanded{#2}}}}%
\blx@tempc}}

\def\blx@seqrange@comp#1#2{%
\def\blx@tempb{#1}%
\def\blx@tempc{#2}%
\expandafter\blx@seqrange@comp@div
}

\def\blx@seqrange@end{%
\numdef\blx@tempb\blx@tempb
\numdef\blx@tempc\blx@tempc
\begingroup
\protected@edef\blx@tempb{\endgroup
\blx@range@out@value{%
\blx@range@out@item@process{\blx@tempb}%
\noexpand\bibrangedash
\blx@range@out@item@process{\blx@tempc}}}%
\blx@tempb}

\def\blx@seqrange@psq{%
\numdef\blx@tempb\blx@tempb
\begingroup
\protected@edef\blx@tempb{\endgroup
\blx@range@out@value{%
\blx@range@out@item@process{\blx@tempb}%
\noexpand\psq}}%
\blx@tempb}

\def\blx@seqrange@psqq{%
\numdef\blx@tempb\blx@tempb
\begingroup
\protected@edef\blx@tempb{\endgroup
\blx@range@out@value{%
\blx@range@out@item@process{\blx@tempb}%
\noexpand\psqq}}%
\blx@tempb}

\def\blx@seqrange@comp@div{%
\blx@tempcnta\blx@tempb\relax
\blx@tempcntb\blx@tempc\relax
\advance\blx@tempcntb-\blx@tempcnta
\ifnum\blx@tempcntb=1
\expandafter\blx@seqrange@psq
\else
\iftoggle{blx@twopagesq}{%
\expandafter\blx@seqrange@end
}{%
\iftoggle{blx@allpagesq}{%
\expandafter\blx@seqrange@psqq
}{%
\ifnum\blx@tempcntb=2
\expandafter\blx@seqrange@psqq
\else
\expandafter\blx@seqrange@end
\fi
}%
}%
\fi}

% <*>[<postpro>]{<string>}
\newrobustcmd*{\mkautorange}{%
\iftoggle{blx@pagesq}%
{\mkseqrange}
{\iftoggle{blx@pagecomp}%
{\mkcomprange}
{\mknormrange}%
}%
}

% <*>[<postpro>]{<string>}
\newrobustcmd*{\mkfirstpage}{%
\begingroup
Expand Down Expand Up @@ -15055,6 +15171,27 @@
\fi}
\def\blx@minxrefs{2}

\DeclareBibliographyOption[string]{citepagerange}{%
\togglefalse{blx@pagecomp}%
\togglefalse{blx@pagesq}%
\togglefalse{blx@allpagesq}%
\togglefalse{blx@twopagesq}%
\ifstrequal{#1}{allsqq}
{\toggletrue{blx@pagesq}\toggletrue{blx@allpagesq}}% allsqq
{\ifstrequal{#1}{3sqq}
{\toggletrue{blx@pagesq}}% 3sqq
{\ifstrequal{#1}{2sq}
{\toggletrue{blx@pagesq}\toggletrue{blx@twopagesq}}% 2sq
{\ifstrequal{#1}{compressed}% compressed
{\toggletrue{blx@pagecomp}}%
{\ifstrequal{#1}{normalized}{}{% normalized
\blx@warning{Invalid citepagerange value `#1'\MessageBreak
Falling back to default.}}}%
}%
}%
}%
}

\DeclareBibliographyOption[string]{texencoding}{%
\ifstrequal{#1}{auto}
{\undef\blx@texencoding@fromoption}
Expand Down

0 comments on commit 4c9a2a8

Please sign in to comment.