von Gast » Di 13. Feb 2018, 17:36
OK. Ich habe da eine Idee. Im Grunde baue ich einfach eine Abfrage ein, ob die Klammer wirklich gesetzt werden muss. Diese Abfrage wird im Original-Makro mit cbx:parens und dem Punctuation tracker realisiert, muss hier aber aufgrund der oben angesprochenen Schwierigkeiten, neu gebaut werden.
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{csquotes}
\usepackage[backend=biber,
style=authoryear-comp,
sorting=nyt,
date=year,
dashed=false,]{biblatex}
\usepackage{hyperref}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{AuthorA2000,
author = {AuthorA},
title = {{TitleA}},
year = {2000}
}
@article{AuthorB2001,
author = {AuthorB},
title = {{TitleB}},
year = {2001}
}
@article{AuthorC2002a,
author = {AuthorC},
title = {{TitleCa}},
year = {2002}
}
@article{AuthorC2002b,
author = {AuthorC},
title = {{TitleCb}},
year = {2002}
}
@article{AuthorC2002c,
author = {AuthorC},
title = {{TitleCc}},
year = {2002}
}
@article{AuthorC2003,
author = {AuthorC},
title = {{TitleC3}},
year = {2003}
}
\end{filecontents}
\addbibresource{\jobname.bib}
%%%set up links for the full citation
%%%start
%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\newrobustcmd{\blx@imc@transparentprinttext}[2][]{%
\ifblank{#2}
{}
{\ifblank{#1}
{\let\blx@theformat\@firstofone}
{\blx@getformat\blx@theformat{ffd}{#1}{}}%
\ifdefvoid\blx@theformat
{}
{\blx@theformat{#2}}}}
\blx@regimcs{\transparentprinttext}
\DeclareCiteCommand{\textcite}[\cbx@textcite@init\cbx@textcite]
{\gdef\cbx@savedkeys{}%
\citetrackerfalse%
\pagetrackerfalse%
\DeferNextCitekeyHook%
\usebibmacro{cite:init}%
\global\undef\cbx@lasthash
\global\undef\cbx@lastyear}
{\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
{\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
\global\clearfield{multipostnote}}
{}%
\xappto\cbx@savedkeys{\thefield{entrykey},}%
\iffieldequals{namehash}{\cbx@lasthash}
{\iffieldequals{labelyear}{\cbx@lastyear}
{\csnumgdef{cbx@textcite@state@\the\c@citecount}{2}}
{\csnumgdef{cbx@textcite@state@\the\c@citecount}{1}%
\savefield{labelyear}{\cbx@lastyear}}}
{\csnumgdef{cbx@textcite@state@\the\c@citecount}{0}%
\stepcounter{textcitetotal}%
\savefield{namehash}{\cbx@lasthash}}}
{}
{\protected@xappto\cbx@savedcites{%
[\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\DeclareFieldFormat{citehyperref}{%
\DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
\bibhyperref{#1}}
\DeclareFieldFormat{textcitehyperref}{%
\DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
\bibhyperref{%
#1%
\ifnumgreater{\value{citecount}+1}{\value{citetotal}}
{\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}}
{\ifnumequal{\csuse{cbx@textcite@state@\the\numexpr\c@citecount+1\relax}}{0}
{\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}}
{}}}}
\savebibmacro{cite}
\savebibmacro{textcite}
\renewbibmacro*{cite}{%
\printtext[citehyperref]{%
\restorebibmacro{cite}%
\usebibmacro{cite}}}
%%%%%comment the following to remove links and error
%%%start comment
\renewbibmacro*{textcite}{%
\ifboolexpr{
( not test {\iffieldundef{prenote}} and
test {\ifnumequal{\value{citecount}}{1}} )
or
( not test {\iffieldundef{postnote}} and
test {\ifnumequal{\value{citecount}}{\value{citetotal}}} )
}
{\DeclareFieldAlias{textcitehyperref}{noformat}}
{}%
\transparentprinttext[textcitehyperref]{%
\restorebibmacro{textcite}%
\usebibmacro{textcite}}}
\makeatother
%%%end comment
%%%%%%%%%%%%%%%%%%%%%%%%%
%%%finish
\begin{document}
First, single cites which are working: \textcite{AuthorA2000} and so on \textcite{AuthorB2001} and so on \textcite{AuthorC2002a} and so on \textcite{AuthorC2002b} and so on \textcite{AuthorC2002c}. This works!
\par
Now combined: Different Authors \\
Two: \textcite{AuthorA2000,AuthorB2001}\\
Three: \textcite{AuthorA2000,AuthorB2001,AuthorC2002a}\\
Works again! \par
Now combined, single author same year
The problem if linking is on: \textcite{AuthorC2002a,AuthorC2002b,AuthorC2002c} \par
Same Author, diff year: Same problem: \textcite{AuthorC2002a,AuthorC2003}
\printbibliography
\end{document}
Ich kann nicht ausschließen, das das anderswo kaputt geht. Wenn Du ein Problem findest, melde Dich bitte einfach mit einem
Minimalbeispiel wieder.
OK. Ich habe da eine Idee. Im Grunde baue ich einfach eine Abfrage ein, ob die Klammer wirklich gesetzt werden muss. Diese Abfrage wird im Original-Makro mit [tt]cbx:parens[/tt] und dem Punctuation tracker realisiert, muss hier aber aufgrund der oben angesprochenen Schwierigkeiten, neu gebaut werden.
[code]\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{csquotes}
\usepackage[backend=biber,
style=authoryear-comp,
sorting=nyt,
date=year,
dashed=false,]{biblatex}
\usepackage{hyperref}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{AuthorA2000,
author = {AuthorA},
title = {{TitleA}},
year = {2000}
}
@article{AuthorB2001,
author = {AuthorB},
title = {{TitleB}},
year = {2001}
}
@article{AuthorC2002a,
author = {AuthorC},
title = {{TitleCa}},
year = {2002}
}
@article{AuthorC2002b,
author = {AuthorC},
title = {{TitleCb}},
year = {2002}
}
@article{AuthorC2002c,
author = {AuthorC},
title = {{TitleCc}},
year = {2002}
}
@article{AuthorC2003,
author = {AuthorC},
title = {{TitleC3}},
year = {2003}
}
\end{filecontents}
\addbibresource{\jobname.bib}
%%%set up links for the full citation
%%%start
%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\newrobustcmd{\blx@imc@transparentprinttext}[2][]{%
\ifblank{#2}
{}
{\ifblank{#1}
{\let\blx@theformat\@firstofone}
{\blx@getformat\blx@theformat{ffd}{#1}{}}%
\ifdefvoid\blx@theformat
{}
{\blx@theformat{#2}}}}
\blx@regimcs{\transparentprinttext}
\DeclareCiteCommand{\textcite}[\cbx@textcite@init\cbx@textcite]
{\gdef\cbx@savedkeys{}%
\citetrackerfalse%
\pagetrackerfalse%
\DeferNextCitekeyHook%
\usebibmacro{cite:init}%
\global\undef\cbx@lasthash
\global\undef\cbx@lastyear}
{\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
{\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
\global\clearfield{multipostnote}}
{}%
\xappto\cbx@savedkeys{\thefield{entrykey},}%
\iffieldequals{namehash}{\cbx@lasthash}
{\iffieldequals{labelyear}{\cbx@lastyear}
{\csnumgdef{cbx@textcite@state@\the\c@citecount}{2}}
{\csnumgdef{cbx@textcite@state@\the\c@citecount}{1}%
\savefield{labelyear}{\cbx@lastyear}}}
{\csnumgdef{cbx@textcite@state@\the\c@citecount}{0}%
\stepcounter{textcitetotal}%
\savefield{namehash}{\cbx@lasthash}}}
{}
{\protected@xappto\cbx@savedcites{%
[\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\DeclareFieldFormat{citehyperref}{%
\DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
\bibhyperref{#1}}
\DeclareFieldFormat{textcitehyperref}{%
\DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
\bibhyperref{%
#1%
\ifnumgreater{\value{citecount}+1}{\value{citetotal}}
{\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}}
{\ifnumequal{\csuse{cbx@textcite@state@\the\numexpr\c@citecount+1\relax}}{0}
{\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}}
{}}}}
\savebibmacro{cite}
\savebibmacro{textcite}
\renewbibmacro*{cite}{%
\printtext[citehyperref]{%
\restorebibmacro{cite}%
\usebibmacro{cite}}}
%%%%%comment the following to remove links and error
%%%start comment
\renewbibmacro*{textcite}{%
\ifboolexpr{
( not test {\iffieldundef{prenote}} and
test {\ifnumequal{\value{citecount}}{1}} )
or
( not test {\iffieldundef{postnote}} and
test {\ifnumequal{\value{citecount}}{\value{citetotal}}} )
}
{\DeclareFieldAlias{textcitehyperref}{noformat}}
{}%
\transparentprinttext[textcitehyperref]{%
\restorebibmacro{textcite}%
\usebibmacro{textcite}}}
\makeatother
%%%end comment
%%%%%%%%%%%%%%%%%%%%%%%%%
%%%finish
\begin{document}
First, single cites which are working: \textcite{AuthorA2000} and so on \textcite{AuthorB2001} and so on \textcite{AuthorC2002a} and so on \textcite{AuthorC2002b} and so on \textcite{AuthorC2002c}. This works!
\par
Now combined: Different Authors \\
Two: \textcite{AuthorA2000,AuthorB2001}\\
Three: \textcite{AuthorA2000,AuthorB2001,AuthorC2002a}\\
Works again! \par
Now combined, single author same year
The problem if linking is on: \textcite{AuthorC2002a,AuthorC2002b,AuthorC2002c} \par
Same Author, diff year: Same problem: \textcite{AuthorC2002a,AuthorC2003}
\printbibliography
\end{document}[/code]
Ich kann nicht ausschließen, das das anderswo kaputt geht. Wenn Du ein Problem findest, melde Dich bitte einfach mit einem [m][/m] wieder.