biblatex: textcite Link, Fehler bei einem Autor

Antwort erstellen


Diese Frage dient dazu, das automatisierte Versenden von Formularen durch Spam-Bots zu verhindern.
Smilies
:D :) :( :o :shock: :? 8) :lol: :-x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:

BBCode ist eingeschaltet
[img] ist eingeschaltet
[flash] ist ausgeschaltet
[url] ist eingeschaltet
Smilies sind eingeschaltet

Die letzten Beiträge des Themas

Ich habe die Datenschutzerklärung gelesen und bin damit einverstanden.

   

Wenn du eine Datei oder mehrere Dateien anhängen möchtest, gib die Details unten ein.

Ansicht erweitern Die letzten Beiträge des Themas: biblatex: textcite Link, Fehler bei einem Autor

von max3.2 » Mi 14. Feb 2018, 09:33

Wow, vielen Dank. Das sieht soweit gut aus bei mir, neue Fehler tauchen vorerst keine auf. Ich teste weiter, wenn ich noch was finde schreibe ich hier.
Ein minimales Detail (was aber wirklich auch zu verschmerzen ist): Bei Zitat mit verschiedenen Autoren und damit dem Füllwort "und" wird dieses auch verklinkt, und zwar auf den darauffolgenden Autor...

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.

-

von max3.2 » Di 13. Feb 2018, 17:22

Na immerhin keim dummer Fehler..oder schade? Weiß nicht...
Wenn du was findest, ich bin sicher nicht der Einzige der sich freut...
Eine Frage zum Makro: Was bedeutet denn das cbx:parens? Mit dem Rest komme ich soweit klar...

Grüße

von Gast » Di 13. Feb 2018, 16:34

Da hast Du einen der Gründe gefunden, warum https://tex.stackexchange.com/q/15951/35864 noch nicht Teil des Voreinstellungen von biblatex ist. Siehe auch https://github.com/plk/biblatex/issues/428

Es gibt hier zwei Probleme. Eins davon kann man vergleichsweise einfach lösen (ein \printtext müsste transparent für den Punctuation tracker werden), aber das andere ist ein ganz anderes Kaliber (das Problem ist die Klammer in textcitehyperref, die müsste eigentlich über ein \setunit realisiert werden, aber das geht nicht). Die einzige Lösung, die mir einfällt, würde verlangen, dass das ganze textcite-Makro umgeschrieben wird, und da bin ich mir nicht sicher, ob das überhaupt funktionieren kann. Ich werde mir das mal ansehen, wenn ich Zeit habe, aber ich möchte Dir keine großen Hoffnungen machen.

biblatex: textcite Link, Fehler bei einem Autor

von max3.2 » Di 13. Feb 2018, 15:41

Hallo,

ich benutze biblatex und habe bei meinem Layout ein Problem was ich nicht in den Griff bekomme.

Zitatstil ist authoryear. Funktioniert ohne extras so wie es soll. Reproduzierbar durch auskommentieren des markierten Makros. Per default ist dann aber nur das Jahr als Link ausgeführt.
Also habe ich mich schlau gemacht und das unten eingefügte Makro gefunden. Auch das funktioniert (fast): Der gesamte Name wird verlinkt.
Wenn jedoch mit Verlinkung (Makro nicht kommentiert) per \textcite mehrere Referenzen des gleichen Autors aufgerufen werden, klappt die Klammersetzung nicht mehr. Ich steige leider nicht komplett durch das Makro durch...kann da jemand helfen?

Grüße

MWE
\documentclass{article}
\usepackage[ngerman]{babel}

\usepackage{csquotes}
\usepackage{hyperref}
\usepackage[backend=biber,
			style=authoryear-comp,
			sorting=nyt,
			date=year,
			dashed=false,]{biblatex}
\addbibresource{testbib.bib}

%%%set up links for the full citation
%%%start
%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareFieldFormat{citehyperref}{%
	\DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
	\bibhyperref{#1}}

\DeclareFieldFormat{textcitehyperref}{%
	\DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
	\bibhyperref{%
		#1%
		\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}}
	{}%
	\printtext[textcitehyperref]{%
		\restorebibmacro{textcite}%
		\usebibmacro{textcite}}}
%%%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}
bibfile
@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}
}


Nach oben