如何右对齐 newlfm 类中的 addrfrom、phonefrom 和 emailfrom?

如何右对齐 newlfm 类中的 addrfrom、phonefrom 和 emailfrom?

我是 LaTeX 新手,我一直在努力寻找解决方案,如何右对齐我放置地址、电话和电子邮件的标题。由于我的名字很长,我的电子邮件很长,所以标题是这样的布局错误

我怎样才能右对齐整个块以使其看起来更美观?我试过\addrfromright但似乎不起作用。

以下是源代码:

\documentclass[11pt,stdletter,dateno,sigleft]{newlfm}

\usepackage{charter} % Use the Charter font for the document text

\newsavebox{\Luiuc}\sbox{\Luiuc}{\parbox[b]{1.75in}{\vspace{0.5in}
\includegraphics[width=1.2\linewidth]{BNP.png}}} % Company/institution logo at the top left of the page
\makeletterhead{Uiuc}{\Lheader{\usebox{\Luiuc}}}

\newlfmP{sigsize=50pt} % Slightly decrease the height of the signature field
\newlfmP{addrfromphone} % Print a phone number under the sender's address
\newlfmP{addrfromemail, addrfromright} % Print an email address under the sender's address
\PhrPhone{Phone} % Customize the "Telephone" text
\PhrEmail{Email} % Customize the "E-mail" text

\lthUiuc % Print the company/institution logo

\namefrom{Nurzhan Kanatzhanov} % Name

\addrfrom{
\today\\[12pt] % Date
Nurzhan Kanatzhanov \\
6515 Wydown Blvd. \\ % Address
St. Louis, MO 63105
}

\phonefrom{(508) 410-1317} % Phone number

\emailfrom{[email protected]} % Email address

\greetto{Dear Mrs. Smith,} % Greeting text
\closeline{Sincerely yours,} % Closing text

\nameto{Mrs. Jane Smith} % Addressee of the letter above the to address

\addrto{
Recruitment Officer \\ % To address
The Corporation \\
123 Pleasant Lane \\
City, State 12345
}

\begin{document}
\begin{newlfm}

PARAGRAPH ONE: State the reason for the letter, name the position or type of work you are applying for and identify the source from which you learned of the opening (i.e. career development center, newspaper, employment service, personal contact).

PARAGRAPH TWO: Indicate why you are interested in the position, the company, its products, services - above all, stress what you can do for the employer. If you are a recent graduate, explain how your academic background makes you a qualified candidate for the position. If you have practical work experience, point out specific achievements or unique qualifications. Try not to repeat the same information the reader will find in the resume. Refer the reader to the enclosed resume or application which summarizes your qualifications, training, and experiences. The purpose of this section is to strengthen your resume by providing details which bring your experiences to life. 

PARAGRAPH THREE: Request a personal interview and indicate your flexibility as to the time and place. Repeat your phone number in the letter and offer assistance to help in a speedy response. For example, state that you will be in the city where the company is located on a certain date and would like to set up an interview. Alternatively, state that you will call on a certain date to set up an interview. End the letter by thanking the employer for taking time to consider your credentials. 

\end{newlfm}
\end{document}

答案1

这里的问题分为两部分:

  1. 软件包fancyhdr已更改,因此命令\fancy@reset\f@ncyolh\f@ncyorh不再在软件包的当前版本中定义fancyhdr。您应该向类的维护者写一份错误报告newlfm。顺便说一句:这已经在中提到过这个问题
  2. 似乎有一个错误,没有正确使用您使用命令调用的newlfm类选项。您应该向类的管理员写一份错误报告。在以下 mwe 中,我做了一个肮脏的补丁,让写信人的地址左边不整齐,但这不是该类的解决方案。应该添加选项(在我看来,它不是为打印地址而评估的)才能在类中正常工作!addrfromright\newlfmP{addrfromright}newlfmaddrfromright

请参阅以下补丁:

% Patches
\usepackage{etoolbox}
\makeatletter
% https://tex.stackexchange.com/questions/377454/undefined-control-sequence-error-on-fancyreset-fncyolh-and-fncyorh-when-u
\patchcmd{\@zfancyhead}{\fancy@reset}{\f@nch@reset}{}{}
\patchcmd{\@set@em@up}{\f@ncyolh}{\f@nch@olh}{}{}
\patchcmd{\@set@em@up}{\f@ncyolh}{\f@nch@olh}{}{}
\patchcmd{\@set@em@up}{\f@ncyorh}{\f@nch@orh}{}{}

% https://tex.stackexchange.com/questions/497642/how-to-right-align-the-addrfrom-phonefrom-and-emailfrom-in-the-newlfm-class
\patchcmd{\openlfm}{%
  \noindent%
  \begin{tabular}{l@{}}%
}{%
  \noindent%
  \begin{tabular}{r@{}}%
}{}{\error}
\makeatother

并查看以下完整的 mwe:

\documentclass[%
  11pt,
  stdletter,
  dateno,
  sigleft,
]{newlfm}

\usepackage{charter} % Use the Charter font for the document text

% Patches
\usepackage{etoolbox}
\makeatletter
% https://tex.stackexchange.com/questions/377454/undefined-control-sequence-error-on-fancyreset-fncyolh-and-fncyorh-when-u
\patchcmd{\@zfancyhead}{\fancy@reset}{\f@nch@reset}{}{}
\patchcmd{\@set@em@up}{\f@ncyolh}{\f@nch@olh}{}{}
\patchcmd{\@set@em@up}{\f@ncyolh}{\f@nch@olh}{}{}
\patchcmd{\@set@em@up}{\f@ncyorh}{\f@nch@orh}{}{}

% https://tex.stackexchange.com/questions/497642/how-to-right-align-the-addrfrom-phonefrom-and-emailfrom-in-the-newlfm-class
\patchcmd{\openlfm}{%
  \noindent%
  \begin{tabular}{l@{}}%
}{%
  \noindent%
  \begin{tabular}{r@{}}%
}{}{\error}
\makeatother


\newsavebox{\Luiuc}\sbox{\Luiuc}{\parbox[b]{1.75in}{\vspace{0.5in}
\includegraphics[width=2cm]{example-image}}} % Company/institution logo at the top left of the page BNP.png
\makeletterhead{Uiuc}{\Lheader{\usebox{\Luiuc}}}

\newlfmP{sigsize=50pt} % Slightly decrease the height of the signature field
\newlfmP{addrfromphone} % Print a phone number under the sender's address
\newlfmP{addrfromemail} % Print an email address under the sender's address
\newlfmP{addrfromright} 
\PhrPhone{Phone} % Customize the "Telephone" text
\PhrEmail{Email} % Customize the "E-mail" text

\lthUiuc % Print the company/institution logo

\namefrom{Nurzhan Kanatzhanov} % Name

\addrfrom{% 
\today\\[12pt] % Date
Nurzhan Kanatzhanov \\
6515 Wydown Blvd. \\ % Address
St. Louis, MO 63105
}
\phonefrom{(508) 410-1317} % Phone number
\emailfrom{[email protected]} % Email address

\greetto{Dear Mrs. Smith,} % Greeting text
\closeline{Sincerely yours,} % Closing text

\nameto{Mrs. Jane Smith} % Addressee of the letter above the to address

\addrto{
Recruitment Officer \\ % To address
The Corporation \\
123 Pleasant Lane \\
City, State 12345
}

\begin{document}
\begin{newlfm}

PARAGRAPH ONE: State the reason for the letter, name the position or type of work you are applying for and identify the source from which you learned of the opening (i.e. career development center, newspaper, employment service, personal contact).

PARAGRAPH TWO: Indicate why you are interested in the position, the company, its products, services - above all, stress what you can do for the employer. If you are a recent graduate, explain how your academic background makes you a qualified candidate for the position. If you have practical work experience, point out specific achievements or unique qualifications. Try not to repeat the same information the reader will find in the resume. Refer the reader to the enclosed resume or application which summarizes your qualifications, training, and experiences. The purpose of this section is to strengthen your resume by providing details which bring your experiences to life. 

PARAGRAPH THREE: Request a personal interview and indicate your flexibility as to the time and place. Repeat your phone number in the letter and offer assistance to help in a speedy response. For example, state that you will be in the city where the company is located on a certain date and would like to set up an interview. Alternatively, state that you will call on a certain date to set up an interview. End the letter by thanking the employer for taking time to consider your credentials. 

\end{newlfm}
\end{document}

及其结果:

生成的字母

我不确定这个类是否真的在维护,而且它有点旧了。您是否考虑过改用scrlttr2KOMA-Script?

相关内容