如何防止 minipage 创建空白页并启用多个页面?

如何防止 minipage 创建空白页并启用多个页面?

我有一封信函的模板,我想在左边显示发件人的信息,在右边显示收件人和信函的内容:

\documentclass{letter}
\usepackage{lipsum} % for dummy text, you can remove this in your actual letter
\usepackage[margin=1in]{geometry}

\begin{document}

\begin{letter}{Receiver's Name \\
Receiver's Address \\
Receiver's City, State, Zip Code}

\begin{minipage}[t]{0.25\textwidth}
\raggedright
\textbf{Sender's Name} \\
Sender's Address \\
Sender's City, State, Zip Code \\
Sender's Email \\
Sender's Phone Number
\end{minipage}
\hfill
\begin{minipage}[t]{0.75\textwidth}
\raggedright
\opening{Dear Receiver,}

\lipsum[1-15] % Your letter text goes here

\closing{Sincerely,}
\end{minipage}

\end{letter}

问题有两个方面:

  1. 它创建一个空白的第一页;
  2. 必要时信件内容不要跨越多页。

答案1

这是一个 paracol 解决方案。字母 environamet 是在 paracol 内部还是外部并不重要,只要开口在内部即可。

请注意不会被或\raggedright关闭。您可以将其放在组内或改用 flushleft 环境。另请参阅\sloppy\fussy这个问题

\documentclass{letter}
\usepackage{lipsum} % for dummy text, you can remove this in your actual letter
\usepackage[margin=1in]{geometry}
\usepackage{paracol}
\globalcounter*

\begin{document}
\setcolumnwidth{0.2\textwidth}% second column gets rest of page
\begin{paracol}{2}
\raggedright
\textbf{Sender's Name} \\
Sender's Address \\
Sender's City, State, Zip Code \\
Sender's Email \\
Sender's Phone Number

\switchcolumn
\begin{letter}{Receiver's Name \\
Receiver's Address \\
Receiver's City, State, Zip Code}

\opening{Dear Receiver,}

\lipsum[1-15] % Your letter text goes here

\closing{Sincerely,}
\end{letter}
\end{paracol}

\end{document}

答案2

您看到的问题是由于minipage形成了一个无法打破的盒子而导致的。由于这个盒子太大,无法放在一页纸上,因此第一页留空,盒子放在第二页上。

您可以执行以下操作:

  • 增加左边距。
  • 将发件人放在左边距
  • 排版信件\raggedright,无需minipage
\usepackage[margin=1in,left=2in]{geometry}
...
\llap{\raisebox{-5ex}[0pt][0pt]{%
\begin{tabular}[t]{l}
  \textbf{Sender's Name} \\
  Sender's Address \\
  Sender's City\\
  State, Zip Code \\
  Sender's Email \\
  Sender's Phone Number
\end{tabular}%
\hspace{1em}}}
\raggedright
\opening{Dear Receiver,}

在此处输入图片描述

\documentclass{letter}
\usepackage{lipsum} % for dummy text, you can remove this in your actual letter
\usepackage[margin=1in,left=2in]{geometry}

\begin{document}

\begin{letter}{Receiver's Name \\
Receiver's Address \\
Receiver's City, State, Zip Code}

\llap{\raisebox{-5ex}[0pt][0pt]{%
\begin{tabular}[t]{l}
  \textbf{Sender's Name} \\
  Sender's Address \\
  Sender's City\\
  State, Zip Code \\
  Sender's Email \\
  Sender's Phone Number
\end{tabular}%
\hspace{1em}}}
\raggedright
\opening{Dear Receiver,}

\lipsum[1-15] % Your letter text goes here

\closing{Sincerely,}

\end{letter}
\end{document}

相关内容