我想在胶片上画一条任意粗细的水平线,为此我使用了 tikz。一切都很好,只是 LaTeX 在线的开头插入了一个间隙,这让一切看起来不对称。
\documentclass{beamer}
\usepackage{tikz}
\setlength{\parindent}{0pt}
\newcommand{\fhline}[1]{%
\begin{tikzpicture}[scale=\textwidth/1cm,outer sep=-5mm]
\draw[line width=#1pt] (0,0) -- (1,0);
\end{tikzpicture}}
\title{There Is No Largest Prime Number}
\subtitle{Testttl}
\date[ISPN ’80]{27th International Symposium of Prime Numbers}
\author[Euclid]{Euclid of Alexandria \texttt{[email protected]}}
\setbeamertemplate{title page}
{%
\fhline{3}
\vskip0.2em
\begin{minipage}{\textwidth}
\ifx\insertsubtitle\empty
\usebeamerfont{title}\inserttitle
\else
\usebeamerfont{title}\inserttitle\par
\vskip0.5em
\usebeamerfont{subtitle}\insertsubtitle
\fi
\end{minipage}
\vskip0.3em
%greenline
\fhline{1}
\vskip3.0cm
\begin{minipage}{\textwidth}
\ifx\insertauthor\empty
\else
\usebeamerfont{author}\insertauthor\par
\fi
\ifx\insertdate\empty
\else
\usebeamerfont{author}\insertdate\\
\fi
\end{minipage}
\vskip1.0cm
}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\end{document}
好像:
答案1
原则上我同意 @samcarter 的观点,tikz
对于绘制水平线来说,这有点过头了,但一旦创建了更多花哨的功能,问题就会变得更加严重。根据我的发现,\centerline
这确实有效。在某种程度上,这个“技巧”已经被使用过了这里,在那里人们可以找到这些奇特的线条。
\documentclass{beamer}
\usepackage{tikz}
\usepackage{lipsum}
\setlength{\parindent}{0pt}
\newcommand{\fhline}[1]{%
\centerline{\tikz[scale=\textwidth/1cm,outer sep=-5mm]{%
\draw[-,line width=#1pt] (0,0) -- (1,0);}}}
\date[$\pi$ day]{27th International Symposium of Prime Numbers}
\title{There Is No Largest Prime Number}
\subtitle{Testttl}
\author[Euclid]{Euclid of Alexandria \texttt{[email protected]}}
\setbeamertemplate{title page}
{%
\fhline{3}
\vskip0.2em
\begin{minipage}{\textwidth}
\ifx\insertsubtitle\empty
\usebeamerfont{title}\inserttitle
\else
\usebeamerfont{title}\inserttitle\par
\vskip0.5em
\usebeamerfont{subtitle}\insertsubtitle
\fi
\end{minipage}
\vskip0.3em
%greenline
\fhline{1}
\vskip3.0cm
\begin{minipage}{\textwidth}
\ifx\insertauthor\empty
\else
\usebeamerfont{author}\insertauthor\par
\fi
\ifx\insertdate\empty
\else
\usebeamerfont{author}\insertdate\\
\fi
\end{minipage}
\vskip1.0cm
}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{A somewhat more serious test}
\begin{overlayarea}{\textwidth}{\textheight}
\fhline{3}
\lipsum[1]
\fhline{2}
\end{overlayarea}
\end{frame}
\end{document}
请注意,我在尝试复制原始代码时遇到了困难,因为后面的方括号中似乎有一些奇怪的字符\date
。
答案2
我个人的看法是:tikz
画一条简单的线是有点小题大做。
\documentclass{beamer}
\newcommand{\fhline}[1]{%
\rule{\textwidth}{#1pt}%
}
\title{There Is No Largest Prime Number}
\subtitle{Testttl}
\date[ISPN ’80]{27th International Symposium of Prime Numbers}
\author[Euclid]{Euclid of Alexandria \texttt{[email protected]}}
\setbeamertemplate{title page}{%
\fhline{3}
\vskip0.2em
\begin{minipage}{\textwidth}
\ifx\insertsubtitle\empty
\usebeamerfont{title}\inserttitle
\else
\usebeamerfont{title}\inserttitle\par
\vskip0.5em
\usebeamerfont{subtitle}\insertsubtitle
\fi
\end{minipage}
\vskip0.3em
\fhline{1}
\vskip3.0cm
\begin{minipage}{\textwidth}
\ifx\insertauthor\empty
\else
\usebeamerfont{author}\insertauthor\par
\fi
\ifx\insertdate\empty
\else
\usebeamerfont{author}\insertdate\\
\fi
\end{minipage}
\vskip1.0cm
}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\end{document}