tufte-latex: citas de biblatex en subtítulos

tufte-latex: citas de biblatex en subtítulos

¿Cómo se pueden utilizar las citas biblatex en los títulos de la clase de documentos tufte-book?

El siguiente MWE no funciona porque \autocitetufte-book no maneja correctamente el comando en el título de la imagen. Supongo que la nota al margen debe estar en cola en algún lugartufte-common.def.

% !TeX program = pdflatex
% !TeX encoding = UTF-8
% !TeX spellcheck = en-US
% !BIB program = biber
\documentclass[a4paper,twoside,justified,marginals=raggedright,nobib]{tufte-book}
\usepackage{graphicx}

\usepackage[%
    backend=biber,
    bibstyle=authoryear,
    citestyle=authortitle-icomp,    
    ]{biblatex}%

\addbibresource{biblatex-examples.bib}

\begin{document}
    Citation in text.\autocite{westfahl:space}
    \begin{figure}
        \includegraphics{example-grid-100x100pt}
        \caption{Citation in caption.\autocite{westfahl:space}}
    \end{figure}
\end{document}

Respuesta1

De forma predeterminada, a las clases de Tufte no les gusta mucho que uses un archivo \footnotedesde dentro de un archivo \caption. Como biblatexno sabe que estamos usando \autocitedesde dentro de a , \captionel valor predeterminado es \footcite; de hecho, dado que falló el parche del \footnotecomando, biblatexni siquiera puedo detectarlo en una nota al pie y usarlo \parenciteallí.

Con

\makeatletter
\long\def\@caption#1[#2]#3{%
  \expandafter\ifx\csname if@capstart\expandafter\endcsname
                  \csname iftrue\endcsname
    \global\let\@currentHref\hc@currentHref
  \else
    \hyper@makecurrent{\@captype}%
  \fi
  \@ifundefined{NR@gettitle}{%
    \def\@currentlabelname{#2}%
  }{%
    \NR@gettitle{#2}%
  }%
  \par\addcontentsline{\csname ext@#1\endcsname}{#1}{%
    \protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}%
  }%
  \begingroup
    \toggletrue{blx@footnote}%
    \@parboxrestore
    \if@minipage
      \@setminipage
    \fi
    \@tufte@caption@font\@tufte@caption@justification%
    \expandafter\ifx\csname if@capstart\expandafter\endcsname
                    \csname iftrue\endcsname
      \global\@capstartfalse
      %\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces#3}%
      \noindent\csname fnum@#1\endcsname: \ignorespaces#3%
    \else
      %\@makecaption{\csname fnum@#1\endcsname}{%
      \noindent\csname fnum@#1\endcsname:
        \ignorespaces
        \ifHy@nesting
          \expandafter\hyper@@anchor\expandafter{\@currentHref}{#3}%
        \else
          \Hy@raisedlink{%
            \expandafter\hyper@@anchor\expandafter{%
              \@currentHref
            }{\relax}%
          }%
          #3%
        \fi
      %}%
    \fi
    \par
  \endgroup
}

\renewcommand\@footnotetext[2][0pt]{%
  \marginpar{%
    \hbox{}\vspace*{#1}%
    \def\baselinestretch {\setspace@singlespace}%
    \reset@font\footnotesize%
    \@tufte@margin@par% use parindent and parskip settings for marginal text
    \vspace*{-1\baselineskip}\noindent%
    \protected@edef\@currentlabel{%
       \csname p@footnote\endcsname\@thefnmark%
    }%
    \color@begingroup%
       \toggletrue{blx@footnote}%
       \@makefntext{%
         \ignorespaces#2%
       }%
    \color@endgroup%
  }%
}%
\makeatother

una bastardización de tufte-common.deflas definiciones de , partes de lo que hyperref.styhace y parches realizados por biblatex, la detección de notas al pie funcionará y el rastreador \captionde s las tratará como si fueran notas al margen biblatex.

MWE

\documentclass[a4paper,twoside,justified,marginals=raggedright,nobib]{tufte-book}
\usepackage{graphicx}
\usepackage{mwe}

\usepackage[%
    backend=biber,
    bibstyle=authoryear,
    citestyle=authortitle-icomp,    
    ]{biblatex}%

\addbibresource{biblatex-examples.bib}

\makeatletter
\long\def\@caption#1[#2]#3{%
  \expandafter\ifx\csname if@capstart\expandafter\endcsname
                  \csname iftrue\endcsname
    \global\let\@currentHref\hc@currentHref
  \else
    \hyper@makecurrent{\@captype}%
  \fi
  \@ifundefined{NR@gettitle}{%
    \def\@currentlabelname{#2}%
  }{%
    \NR@gettitle{#2}%
  }%
  \par\addcontentsline{\csname ext@#1\endcsname}{#1}{%
    \protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}%
  }%
  \begingroup
    \toggletrue{blx@footnote}%
    \@parboxrestore
    \if@minipage
      \@setminipage
    \fi
    \@tufte@caption@font\@tufte@caption@justification%
    \expandafter\ifx\csname if@capstart\expandafter\endcsname
                    \csname iftrue\endcsname
      \global\@capstartfalse
      %\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces#3}%
      \noindent\csname fnum@#1\endcsname: \ignorespaces#3%
    \else
      %\@makecaption{\csname fnum@#1\endcsname}{%
      \noindent\csname fnum@#1\endcsname:
        \ignorespaces
        \ifHy@nesting
          \expandafter\hyper@@anchor\expandafter{\@currentHref}{#3}%
        \else
          \Hy@raisedlink{%
            \expandafter\hyper@@anchor\expandafter{%
              \@currentHref
            }{\relax}%
          }%
          #3%
        \fi
      %}%
    \fi
    \par
  \endgroup
}

\renewcommand\@footnotetext[2][0pt]{%
  \marginpar{%
    \hbox{}\vspace*{#1}%
    \def\baselinestretch {\setspace@singlespace}%
    \reset@font\footnotesize%
    \@tufte@margin@par% use parindent and parskip settings for marginal text
    \vspace*{-1\baselineskip}\noindent%
    \protected@edef\@currentlabel{%
       \csname p@footnote\endcsname\@thefnmark%
    }%
    \color@begingroup%
       \toggletrue{blx@footnote}%
       \@makefntext{%
         \ignorespaces#2%
       }%
    \color@endgroup%
  }%
}%
\makeatother

\begin{document}
    Citation in text.\autocite{westfahl:space}
    \begin{figure}
        \includegraphics{example-grid-100x100pt}
        \caption{Citation in caption. \autocite{westfahl:space}}
    \end{figure}
\end{document}

salida de ejemplo

Respuesta2

Encontré una solución manual basada enUsando \footnote en el \caption de una figura, pero preferiría una solución automatizada.

% !TeX program = pdflatex
% !TeX encoding = UTF-8
% !TeX spellcheck = en-US
% !BIB program = biber
\documentclass[a4paper,twoside,justified,marginals=raggedright,nobib]{tufte-book}
\usepackage{graphicx,lipsum}

\usepackage[%
    backend=biber,
    bibstyle=authoryear,
    citestyle=authortitle-icomp,    
    ]{biblatex}%

\addbibresource{biblatex-examples.bib}

\usepackage{ftnxtra}
\begin{document}
    Citation in text.\autocite{westfahl:space}
    \begin{figure}
        \includegraphics{example-grid-100x100pt}
        \caption{Citation in caption.\footnotemark}
    \end{figure}
    \footnotetext{\cite{westfahl:space}}
\end{document}

información relacionada