下面的代码
\documentclass[12pt, B5]{letter}
\usepackage[b5paper,body={13cm,18cm}]{geometry}
\usepackage[italian,french,spanish,icelandic,english]{babel}
\usepackage{etoolbox} % Programming tools
\title{First document}
\author{Randy}
\date{September 2022}
\signature{Randy}
\address{51 Franklin Street, Fifth Floor \\
Boston, MA 02110 \\
USA}
\begin{document}
\begin{letter}{Local Council}
\opening{Mayor}
A paragraph
\begin{flushright}
\closing{Yours Sincerely,}
\signature{Randy}
\end{flushright}
\end{letter}
\end{document}
正在给予
Overfull \hbox (20.11418pt too wide) in paragraph at lines 154--154
我该如何修复它?
答案1
箱子过满的消息与 无关flushright
,您可以通过删除它来检查。
您可以在类文件中查看以下定义\closing
:
% letter.cls, line 234:
\newcommand\closing[1]{\par\nobreak\vspace{\parskip}%
\stopbreaks
\noindent
\ifx\@empty\fromaddress\else
\hspace*{\longindentation}\fi
\parbox{\indentedwidth}{\raggedright
\ignorespaces #1\\[6\medskipamount]%
\ifx\@empty\fromsig
\fromname
\else \fromsig \fi\strut}%
\par}
如果您查找\longindentation
和的值\indentedwidth
,您会看到两者都是 195pt。它们的总和是 390pt,这是该类的标准文本宽度letter
,但您指定了不同的文本宽度 13cm,以点为单位为 369.88582pt。差异正是您在警告中看到的内容
Overfull \hbox (20.11418pt too wide)
如果您确实希望将结束语和签名推至右边距,则需要修改 的定义\closing
。
\documentclass[12pt,draft]{letter}
\usepackage[b5paper,body={13cm,18cm}]{geometry}
\makeatletter
\renewcommand{\closing}[1]{%
\par\nobreak\vspace{\parskip}%
\stopbreaks
\noindent
\hfill
\begin{tabular}{@{}r@{}}
#1\\[6\medskipamount]
\ifx\@empty\fromsig
\fromname
\else
\fromsig
\fi
\end{tabular}\par
}
\makeatother
\date{September 2022}
\signature{Randy}
\address{51 Franklin Street, Fifth Floor \\
Boston, MA 02110 \\
USA}
\begin{document}
\begin{letter}{Local Council}
\opening{Mayor}
A paragraph
\closing{Yours Sincerely,}
\end{letter}
\end{document}
我不会这么做。如果你想坚持标准方式,让结尾和签名从页面中间开始,那么就改为在序言中添加
\AtBeginDocument{%
\setlength{\longindentation}{0.5\textwidth}%
\setlength{\indentedwidth}{0.5\textwidth}%
}
或者您可以选择不同的比例。
这是示例。
\documentclass[12pt,draft]{letter}
\usepackage[b5paper,body={13cm,18cm}]{geometry}
\AtBeginDocument{%
\setlength{\longindentation}{0.5\textwidth}%
\setlength{\indentedwidth}{0.5\textwidth}%
}
\date{September 2022}
\signature{Randy}
\address{51 Franklin Street, Fifth Floor \\
Boston, MA 02110 \\
USA}
\begin{document}
\begin{letter}{Local Council}
\opening{Mayor}
A paragraph
\closing{Yours Sincerely,}
\end{letter}
\end{document}