为什么 BibLatex \footcite 会扭曲 Beamer 列?

为什么 BibLatex \footcite 会扭曲 Beamer 列?

如下代码所示,在 Beamer 演示文稿中使用 BibLatex \footcite 命令引用了一些参考文献。除引用外,三个 Beamer 页面的内容相同。令人困惑的是,为什么一页中的两列在第二页和第三页中都失真了。

您能帮忙评论一下如何调试和解决这个问题吗?非常感谢!

shell 命令运行

rm MWE1.aux MWE1.bbl MWE1.bcf MWE1.blg MWE1.log MWE1.nav MWE1.out MWE1.pdf MWE1.snm MWE1.toc MWE1.run.xml ; xelatex MWE1.tex && biber MWE1 && xelatex MWE1.tex && xelatex MWE1.tex

MWE1.tex

\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[10pt,ignorenonframetext,]{beamer}
\setbeamertemplate{caption}[numbered]
\setbeamertemplate{caption label separator}{: }
\setbeamercolor{caption name}{fg=normal text.fg}
\beamertemplatenavigationsymbolsempty
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provides euro and other symbols
\else % if luatex or xelatex
  \usepackage{unicode-math}
  \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
    \setmainfont[]{Times New Roman}
  \ifxetex
    \usepackage{xeCJK}
    \setCJKmainfont[]{FangSong}
  \fi
  \ifluatex
    \usepackage[]{luatexja-fontspec}
    \setmainjfont[]{FangSong}
  \fi
\fi
\usefonttheme{serif} % use mainfont rather than sansfont for slide text
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
\usepackage{hyperref}
\hypersetup{
            pdftitle={Sample title},
            pdfauthor={Author},
            pdfborder={0 0 0},
            breaklinks=true}
\urlstyle{same}  % don't use monospace font for urls
\newif\ifbibliography
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Prevent slide breaks in the middle of a paragraph:
\widowpenalties 1 10000
\raggedbottom
\setbeamertemplate{part page}{
\centering
\begin{beamercolorbox}[sep=16pt,center]{part title}
  \usebeamerfont{part title}\insertpart\par
\end{beamercolorbox}
}
\setbeamertemplate{section page}{
\centering
\begin{beamercolorbox}[sep=12pt,center]{part title}
  \usebeamerfont{section title}\insertsection\par
\end{beamercolorbox}
}
\setbeamertemplate{subsection page}{
\centering
\begin{beamercolorbox}[sep=8pt,center]{part title}
  \usebeamerfont{subsection title}\insertsubsection\par
\end{beamercolorbox}
}
\AtBeginPart{
  \frame{\partpage}
}
\AtBeginSection{
  \ifbibliography
  \else
    \frame{\sectionpage}
  \fi
}
\AtBeginSubsection{
  \frame{\subsectionpage}
}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{0}

% set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother

\usepackage{caption}\captionsetup{labelformat=empty,labelsep=none,singlelinecheck=false,justification=centering}
\settowidth{\leftmargini}{\usebeamertemplate{itemize item}}
\addtolength{\leftmargini}{\labelsep}
\setlength{\leftmarginii}{0.5em}
\makeatletter
\@ifpackageloaded{subfig}{}{\usepackage{subfig}}
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\captionsetup[subfloat]{margin=0.5em}
\AtBeginDocument{%
\renewcommand*\figurename{Figure}
\renewcommand*\tablename{Table}
}
\AtBeginDocument{%
\renewcommand*\listfigurename{List of Figures}
\renewcommand*\listtablename{List of Tables}
}
\@ifpackageloaded{float}{}{\usepackage{float}}
\floatstyle{ruled}
\@ifundefined{c@chapter}{\newfloat{codelisting}{h}{lop}}{\newfloat{codelisting}{h}{lop}[chapter]}
\floatname{codelisting}{Listing}
\newcommand*\listoflistings{\listof{codelisting}{List of Listings}}
\makeatother
\usepackage[backend=biber,bibencoding=utf8,citestyle=authortitle,bibstyle=authortitle]{biblatex}
%\renewcommand{\footnotesize}{\tiny}
\addbibresource{MWE1.bib}
\usepackage{xpatch}
\xpretobibmacro{cite}{\printfield{year}\setunit{\nametitledelim}}{}{}

\title{Sample title}
\author{Author}
\date{}

\begin{document}
{
\setbeamertemplate{footline}{} % no page number here
\frame{
  \titlepage
  % Include a note for the title slide here, because we cannot do so in the 
  % Pandoc markdown file. If you want the title note to contain actual text, 
  % use the titlepage-note field in the YAML header. Otherwise, we use a 
  % non-breaking space so that it is not empty.
  \note{~}
}
}

\begin{frame}{Title of frame 1}
\protect\hypertarget{title-of-frame-1}{}

\begin{columns}[T]
\begin{column}{0.50\textwidth}
\begin{block}{Block title 1 on left}

\begin{itemize}
\item
  \small Sentence 1.
\item
  \small \emph{\textbf{Sentence 2.}}
\end{itemize}

\end{block}
\end{column}

\begin{column}{0.50\textwidth}
\begin{figure}
\centering
\includegraphics[width=\textwidth,height=0.8\textheight]{example-image-a}
\caption{\footnotesize \emph{\textbf{Example image}}}
\end{figure}
\end{column}
\end{columns}

\note{NOTES}

\end{frame}

\begin{frame}{Title of frame 2}
\protect\hypertarget{title-of-frame-2}{}

\begin{columns}[T]
\begin{column}{0.50\textwidth}
\begin{block}{Block title 1 on left}

\begin{itemize}
\item
  \small Sentence 1. \autocite{dijkstra1959note}
\item
  \small \emph{\textbf{Sentence 2.}}
\end{itemize}

\end{block}
\end{column}

\begin{column}{0.50\textwidth}
\begin{figure}
\centering
\includegraphics[width=\textwidth,height=0.8\textheight]{example-image-a}
\caption{\footnotesize \emph{\textbf{Example image}}}
\end{figure}
\end{column}
\end{columns}

\note{NOTES}

\end{frame}

\begin{frame}{Title of frame 3}
\protect\hypertarget{title-of-frame-3}{}

\begin{columns}[T]
\begin{column}{0.50\textwidth}
\begin{block}{Block title 1 on left}

\begin{itemize}
\item
  \small Sentence 1. \autocite{dijkstra1959note}
\item
  \small \emph{\textbf{Sentence 2.}}
  \autocites{dijkstra1959note,zipf1946p1}
\end{itemize}

\end{block}
\end{column}

\begin{column}{0.50\textwidth}
\begin{figure}
\centering
\includegraphics[width=\textwidth,height=0.8\textheight]{example-image-a}
\caption{\footnotesize \emph{\textbf{Example image}}}
\end{figure}
\end{column}
\end{columns}

\note{NOTES}

\end{frame}

\end{frame}

\end{document}

MWE1.bib

@article{dijkstra1959note,
    Author = {Dijkstra, Edsger W},
    Date-Added = {2014-04-28 19:35:12 +0000},
    Date-Modified = {2014-04-28 19:35:12 +0000},
    Journal = {Numerische mathematik},
    Number = {1},
    Pages = {269--271},
    Publisher = {Springer},
    Title = {A note on two problems in connexion with graphs},
    Volume = {1},
    Year = {1959}}

@article{zipf1946p1,
    Author = {Zipf, George Kingsley},
    Date-Added = {2014-04-28 19:32:00 +0000},
    Date-Modified = {2014-04-28 19:32:00 +0000},
    Journal = {American sociological review},
    Pages = {677--686},
    Publisher = {JSTOR},
    Title = {The P1 P2/D hypothesis: On the intercity movement of persons},
    Year = {1946}}

更新:

在这篇 SE 文章中lockstep回答似乎解决了这个失真的问题,尽管我不知道原因。

答案1

基于引用位于小页面末尾,而不是框架末尾

\documentclass[10pt,ignorenonframetext]{beamer}

\usepackage{filecontents}
\begin{filecontents*}{MWE1.bib}
@article{dijkstra1959note,
    Author = {Dijkstra, Edsger W},
    Date-Added = {2014-04-28 19:35:12 +0000},
    Date-Modified = {2014-04-28 19:35:12 +0000},
    Journal = {Numerische mathematik},
    Number = {1},
    Pages = {269--271},
    Publisher = {Springer},
    Title = {A note on two problems in connexion with graphs},
    Volume = {1},
    Year = {1959}}

@article{zipf1946p1,
    Author = {Zipf, George Kingsley},
    Date-Added = {2014-04-28 19:32:00 +0000},
    Date-Modified = {2014-04-28 19:32:00 +0000},
    Journal = {American sociological review},
    Pages = {677--686},
    Publisher = {JSTOR},
    Title = {The P1 P2/D hypothesis: On the intercity movement of persons},
    Year = {1946}}
\end{filecontents*}

\usepackage[bibencoding=utf8,citestyle=authortitle,bibstyle=authortitle]{biblatex}
\addbibresource{MWE1.bib}

\begin{document}

\begin{frame}
\frametitle{Title of frame 2}

\begin{columns}[T]
\begin{column}{0.45\textwidth}
\begin{block}{Block title 1 on left}

\begin{itemize}
\item Sentence 1.\footnotemark[1] 
\item Sentence 2.\footnotemark[2]
\end{itemize}

\end{block}
\end{column}

\begin{column}{0.45\textwidth}
\begin{figure}
\includegraphics[width=\textwidth]{example-image-a}
\caption{Example image}
\end{figure}
\end{column}
\end{columns}

\setcounter{footnote}{1}
\footcitetext{dijkstra1959note}
\stepcounter{footnote}
\footcitetext{zipf1946p1}

\end{frame}

\end{document}

其他一些评论:

  • 请不要多次加载同一个包

  • 你不需要hyperref使用 beamer

  • 如果你的 tex 安装是最新的,你不需要fixltx2e

  • pdfborder={0 0 0}没有必要,beamer 已经做到了

  • 硬编码值pdftitle={Sample title}, pdfauthor={Author}不是一个好主意。如果删除它,将使用文档的标题和作者。

  • 你不需要\usepackage{graphicx}使用投影仪

  • 在没有浮点数的文档类中\def\fps@figure{htbp}没有多大意义

  • 我不明白 的意思\@ifpackageloaded{subfig}{}{\usepackage{subfig}} \@ifpackageloaded{caption}{}{\usepackage{caption}}。为什么不使用\RequirePackage{}呢?

  • backend=biber没有必要,因为这是默认行为

  • \protect\hypertarget{title-of-frame-1}{}很奇怪,最好使用\begin{frame}[label=title-of-frame-1]

  • 你不应该有两列.5\textwidth,因为它们之间有一些分离。要么把它们弄小一点,.48\textwidth要么至少使用\begin{columns}[T,onlytextwidth]

  • 格式说明应该与内容分开,因此最好\item \small text使用\setbeamerfont{itemize\enumerate body}{size=\small}。标题字体也一样。

  • 仅指定宽度或高度\includegraphics[width=\textwidth,height=0.8\textheight]{example-image-a},而不是同时指定两者。

一般来说,如果你只加载真正需要的包并且只做所需的修改而不是这种非常混乱的整个厨房水槽序言,那会更好。

相关内容