tufte-latex:字幕中的 biblatex 引文

tufte-latex:字幕中的 biblatex 引文

如何在 tufte-book 文件類別的標題中使用 biblatex 引文?

\autocite由於tufte-book 未正確處理圖像標題中的命令,因此以下 MWE 不起作用。我假設邊注需要在某個地方排隊tufte-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}

答案1

預設情況下,Tufte 類別不太喜歡您\footnote\caption.由於biblatex不知道我們正在使用\autocitea ,\caption因此預設為\footcite;事實上,由於修補\footnote命令失敗,biblatex甚至無法檢測到它在腳註中並\parencite在那裡使用。

\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

的定義的混雜化tufte-common.def、所做的部分hyperref.sty以及由 所做的修補biblatex、腳註檢測將起作用,並且\captions 將被視為 的biblatex跟踪器的旁注。

微量元素

\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}

範例輸出

答案2

我找到了一個基於手動解決方法在圖形的 \caption 中使用 \footnote,但我更喜歡自動化的解決方案。

% !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}

相關內容