![沿发件人地址动态定位 \closing](https://linux22.com/image/455382/%E6%B2%BF%E5%8F%91%E4%BB%B6%E4%BA%BA%E5%9C%B0%E5%9D%80%E5%8A%A8%E6%80%81%E5%AE%9A%E4%BD%8D%20%5Cclosing.png)
在我们在学校学到的格式中, 的位置\closing
与发件人的地址对齐。在下面给出的 MWE 中:我必须通过制定 的规范来\closing
目测调整 的位置。有没有办法自动完成这个?\setlength
\longindentation
我的 MWE:
\documentclass[a4paper,12pt]{letter}
\usepackage[top=1.5cm, left=2.0cm, right=1.5cm, bottom=1.5cm]{geometry}
\usepackage[sfdefault]{atkinson}
\usepackage{microtype}
\setlength\parindent{0cm} % Paragraph indentation
%%% Adjusting the \closing specifications:
%1. Decreases the default gap between the closing remark (Warrm regards) and the senders name.
%2. Looking to make its position align with the sender's address.
\renewcommand\closing[1]{\par\nobreak\vspace{\parskip}%
\stopbreaks%
\noindent%
\ifx\@empty\fromaddress\else%
\hspace*{\longindentation}\fi%
\parbox{\indentedwidth}{\raggedright%
\ignorespaces #1\\[\medskipamount]%
\ifx\@empty\fromsig%
\fromname%
\else \fromsig \fi\strut}%
\par}
%%%%
\signature{Ginko Mitten}
\address{21 Jump Street,\\Mink Road,\\ Uganda}
%%%% dynamic adjustment of closing position %%%
\setlength{\longindentation}{0.78\textwidth}
%%%%%%%%
\begin{document}
\begin{letter}{%
Prof. Minao Sloan,\\
Room 45,\\
University of Computation,\\
Mexico City,\\
Mexico}
\opening{%
\begin{center}
\textbf{Subject}: Our meeting next month.
\end{center}%
Dear Prof. Sloan}
Blah Blah Blah. Quantum computing very interesting. Blah blah blah.\par
Thank you very much for your time. I hope to get in touch with you soon.
\closing{Warm regards,}
\end{letter}
\end{document}
答案1
您需要在 的重新定义周围使用\makeatletter
和,否则将\makeatother
\closing
\ifx\@empty...
总是返回 false 因为它\@
与进行比较e
。
现在让我们解决您的问题:您想要测量“发件人地址”和日期,因此您可以使用\parbox
相同尺寸的。
\documentclass[a4paper,12pt]{letter}
\usepackage[top=1.5cm, left=2.0cm, right=1.5cm, bottom=1.5cm]{geometry}
\usepackage[sfdefault]{atkinson}
\usepackage{microtype}
%%% Adjusting the \closing specifications:
%1. Decreases the default gap between the closing remark (Warrm regards) and the senders name.
%2. Looking to make its position align with the sender's address.
\makeatletter
\renewcommand\closing[1]{%
\par\nobreak\vspace{\parskip}%
\stopbreaks
\ifx\@empty\fromaddress\else
\hspace*{\fill}%
\fi
\sbox0{\begin{tabular}{@{}l@{}}\fromaddress\\\today\end{tabular}}%
\parbox[t]{\wd0}{%
\raggedright
\ignorespaces #1\\[\medskipamount]
\ifx\@empty\fromsig
\fromname
\else
\fromsig
\fi
\strut
}%
\par
}
\makeatother
%%%%
\signature{Ginko Mitten}
\address{21 Jump Street,\\Mink Road,\\ Uganda}
\begin{document}
\begin{letter}{%
Prof. Minao Sloan,\\
Room 45,\\
University of Computation,\\
Mexico City,\\
Mexico}
\opening{%
\begin{center}
\textbf{Subject}: Our meeting next month.
\end{center}%
Dear Prof. Sloan}
Blah Blah Blah. Quantum computing very interesting. Blah blah blah.\par
Thank you very much for your time. I hope to get in touch with you soon.
\closing{Warm regards,}
\end{letter}
\end{document}
(不过,我并不认为这有什么吸引力。)