summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-compatible.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-compatible.sty')
-rw-r--r--Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-compatible.sty87
1 files changed, 70 insertions, 17 deletions
diff --git a/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-compatible.sty b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-compatible.sty
index db70f54c1ce..eedc5dc4a1e 100644
--- a/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-compatible.sty
+++ b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-compatible.sty
@@ -9,7 +9,7 @@
% ### `babel`
% This should be disabled.
-\AtEndOfPackageFile* { babel }
+\hook_gput_code:nnn { package / babel / after } { . }
{
\RenewDocumentCommand \nocite { m }
{
@@ -24,6 +24,54 @@
}
+% ### `backref`
+
+\hook_gput_code:nnn { package / backref / after } { . }
+ {
+ \cs_set:Npn \__csl_add_back_ref_info:
+ { \seq_map_inline:Nn \l__csl_cite_keys_seq { \Hy@backout {##1} } }
+ }
+
+
+% ### `beamer`
+
+% `beamer` passes `implicit=false` to `hyperref` to skip its patch to LaTeX2e
+% internal bibliographic commands. Instead `beamer` refines those commands
+% in its own way.
+
+\cs_new:Npn \__csl_beamer_cite_item:nn #1#2
+ { \hyperlink { beamerbib #1 } { #2 } }
+
+\cs_new:Npn \__csl_beamer_lbibitem:nn [#1]#2
+ {
+ \exp_after:wN \item \beamer@bibstore [ \@biblabel {#1} \hfill ]
+ \cs_if_exist:cF { beamerbib@ #2 @ \int_use:N \c@framenumber }
+ {
+ \cs_gset:cpn { beamerbib@ #2 @ \int_use:N \c@framenumber } { \relax }
+ \hypertarget { beamerbib #2 } { }
+ }
+ \hbox { }
+ \ignorespaces
+ }
+
+\cs_new:Npn \__csl_beamer_lbibitem:n #1
+ {
+ \exp_after:wN \item \beamer@bibstore
+ \cs_if_exist:cF { beamerbib@ #1 @ \int_use:N \c@framenumber }
+ {
+ \cs_gset:cpn { beamerbib@ #1 @ \int_use:N \c@framenumber } { \relax }
+ \hypertarget { beamerbib #1 } { }
+ }
+ }
+
+\hook_gput_code:nnn { class / beamer / after } { . }
+ {
+ \cs_gset_eq:NN \@lbibitem \__csl_beamer_lbibitem:nn
+ \cs_gset_eq:NN \@bibitem \__csl_beamer_bibitem:n
+ \cs_gset_eq:NN \cslcite \__csl_beamer_cite_item:nn
+ }
+
+
% ### `biblatex`
% The following doesn't really make `csl` compatible with `biblatex`.
% It just provides commands to make it accepting `biblatex`'s database.
@@ -37,7 +85,7 @@
% ### `csquotes`
-\AtEndOfPackageFile* { csquotes }
+\hook_gput_code:nnn { package / csquotes / after } { . }
{
\BlockquoteDisable
{
@@ -49,21 +97,6 @@
% ### `hyperref`
-% The hyperref package also patches \bibcite but it cannot provide hyperlinks
-% when used with csl.
-\bool_new:N \l__csl_hyperref_loaded_bool
-\AtEndOfPackageFile* { hyperref }
- {
- \bool_set_true:N \l__csl_hyperref_loaded_bool
- % Pakcage "hyperref" redefines \@lbibitem and \bibitem and we need to
- % recover them.
- \cs_gset_eq:NN \@lbibitem \__csl_lbibitem:
- \cs_gset_eq:NN \@bibitem \__csl_bibitem:
- \cs_gset_eq:NN \__csl_lbibitem_plain:nn \__csl_hyperref_lbibitem:nn
- \cs_gset_eq:NN \__csl_bibitem_plain:n \__csl_hyperref_bibitem:n
- \cs_gset_eq:NN \cslcite \__csl_hyperref_cite_item:nn
- }
-
\cs_set:Npn \__csl_hyperref_cite_item:nn #1#2
{ \hyper@@link [ cite ] { } { cite. #1 \@extra@b@citeb } { #2 } }
@@ -100,3 +133,23 @@
}
\ignorespaces
}
+
+% The hyperref package also patches \bibcite but it cannot provide hyperlinks
+% when used with csl.
+\bool_new:N \l__csl_hyperref_loaded_bool
+\hook_gput_code:nnn { package / hyperref / after } { . }
+ {
+ \bool_set_true:N \l__csl_hyperref_loaded_bool
+ % Pakcage "hyperref" redefines \@lbibitem and \bibitem and we need to
+ % recover them.
+ % In non-implicit mode (e.g., loaded by `beamer`), hyperref stops early
+ % (`\MaybeStopEarly`) and it doesn't redefine the cite internal commands.
+ \cs_if_exist:NT \@extra@b@citeb
+ {
+ \cs_gset_eq:NN \@lbibitem \__csl_lbibitem:
+ \cs_gset_eq:NN \@bibitem \__csl_bibitem:
+ \cs_gset_eq:NN \__csl_lbibitem_plain:nn \__csl_hyperref_lbibitem:nn
+ \cs_gset_eq:NN \__csl_bibitem_plain:n \__csl_hyperref_bibitem:n
+ \cs_gset_eq:NN \cslcite \__csl_hyperref_cite_item:nn
+ }
+ }