创建等间距的引文和标题

创建等间距的引文和标题

我想为即将制作的工作表创建一个标题。我希望在页面最左上角留出空间来显示他们的姓名、课程等(基于页面尺寸),并在页面最右上角留出电视/电影台词。

为了做到这一点,我想使用 minipage 来实现这一点,如下所示:

\begin{minipage}{0.6\textwidth}
\textbf{Name:} \makebox[3in]{\hrulefill} \\ 
\textbf{Course} \\ 
\textbf{Worksheet \#1} \\
\end{minipage}
\begin{minipage}{0.4\textwidth}
{\em ``This is a quote that someone definitely said.'' } \\
\strut\hfill --H.P. Blabbermouth, That One Show You Know
\end{minipage}

在此处输入图片描述

乍一看,这可行。但是,当您向左上角添加更多内容或引用较长时,它们会相互抵消,因此它们不再位于最上角(如下图所示)。有没有办法确保它们始终出现在页面的左上角/右上角?

在此处输入图片描述

答案1

您需要使用[t]op-aligned minipages 来确保它们始终适当对齐:

在此处输入图片描述

\documentclass{article}

\begin{document}

\noindent
\begin{minipage}[t]{0.6\textwidth}
  \textbf{Name:} \hrulefill ~~ \par
  \textbf{Course} \par
  \textbf{Worksheet \#1}
\end{minipage}%
\begin{minipage}[t]{0.4\textwidth}
  \raggedright
  {\itshape ``This is a quote that someone definitely said.''} \par
  \raggedleft
  --H.P.\ Blabbermouth, That One Show You Know
\end{minipage}

\end{document}

答案2

我建议为此使用表格,同时也为这种重复任务定义一个宏,以确保输出始终是统一的。

\documentclass[draft]{article}
\usepackage{array}

\newcommand{\worksheetheader}[3]{%
  % #1 = title of worksheet
  % #2 = quote
  % #3 = attribution
  \par\noindent
  \begin{tabular*}{\textwidth}{
    @{\extracolsep{\fill}}
    >{\raggedright}p{0.58\textwidth}
    >{\raggedright}p{0.38\textwidth}
    @{}
  }
  \bfseries
  Name: \hrulefill\\
  Course\\
  Worksheet #1
  &
  \emph{\makebox[0pt][r]{``}\ignorespaces#2\unskip''}\\
  \raggedleft--- \ignorespaces#3\unskip\\
  \end{tabular*}\par
}

\begin{document}

\worksheetheader{\#1}{
  This is a quote that someone definitely said.
}{
  H.P. Blabbermouth, That One Show You Know
}

\bigskip

\worksheetheader{\#2}{
  This is a quote that someone definitely said.
  This is a quote that someone definitely said.
  This is a quote that someone definitely said.
  This is a quote that someone definitely said.
  This is a quote that someone definitely said.
  This is a quote that someone definitely said.
}{
  H.P. Blabbermouth, That One Show You Know
}

\end{document}

在此处输入图片描述

相关内容