更新

更新

由于信件包没有给我预期的效果,我试图使用常规 LaTex 命令来重新创建信件格式。

在标准的美国信件中,我的(发件人)地址应位于页面的右侧,而我的地址的每一行应与左端齐平。我想知道如何实现这一点?

例子:

办公室 123
一些建筑物
一些名字很长的公司
一些城市
一些邮编 12345
一些国家

我希望我的地址块最长行的右端“某个名称很长的公司”与我的信件正文的右边缘对齐,同时,我的地址块内的所有行都左对齐。

你知道如何在 LaTex 中做到这一点吗?谢谢!

- - 跟进 - -

\documentclass[10pt]{article}

%this is for setting up text fonts, pick one and comment out all others
%\usepackage{charter}
\usepackage{kpfonts}
%\usepackage{Times}
\usepackage{graphicx}
%\usepackage{showframe}
\usepackage{calc}
\usepackage{pbox}
% Text layout
\topmargin -2.0cm
\oddsidemargin 0.2 cm
\evensidemargin 0.4cm
\textwidth 15.5cm
\textheight 25cm
\setlength{\parindent}{0pt}

\begin{document}
\thispagestyle{empty}
\begin{minipage}[t]{\textwidth}
\includegraphics[width=3.5cm]{Olympics.jpg}

\hfill
\begin{tabular}{@{}l@{}}
Office 123 \\
Some building \\
Some company that has a long name\\
Some city, some zip 12345 \\
Some country
\end{tabular}

\end{minipage}
\end{document}

答案1

有很多方法......其中两种:

\hfill您也可以使用来代替{\raggedright <stuff>}。)

代码

\documentclass{article}
\usepackage{showframe}
\usepackage{calc} % for \widthof, can be done without, too (see parbox)
\begin{document}
\hfill

\begin{minipage}{\widthof{Some company that has a long name}}
Office 123 \\
Some building \\
Some company that has a long name \\
Some city, some zip 12345 \\
Some country
\end{minipage}

\hfill
\begin{tabular}{@{}l@{}}
Office 123 \\
Some building \\
Some company that has a long name\\
Some city, some zip 12345 \\
Some country
\end{tabular}

\hfill
\sbox0{Some company that has a long name}% without calc
\parbox{\wd0}{% similar to minipage/not pictured
Office 123 \\
Some building \\
Some company that has a long name\\
Some city, some zip 12345 \\
Some country
}
\end{document}

输出

enter image description here

更新

应该\hrulefill用 代替\hfill。它只是用来显示基线。

代码

\documentclass[10pt]{article}
\usepackage[demo]{graphicx}
\usepackage{calc}
% Text layout
\topmargin -2.0cm
\oddsidemargin 0.2 cm
\evensidemargin 0.4cm
\textwidth 15.5cm
\textheight 25cm
\setlength{\parindent}{0pt}

\begin{document}
\thispagestyle{empty}
\includegraphics[width=3.5cm]{Olympics.jpg}
\hrulefill
\begin{tabular}[b]{@{}l@{}}
Office 123 \\
Some building \\
Some company that has a long name\\
Some city, some zip 12345 \\
Some country
\end{tabular}
\end{document}

输出

enter image description here

相关内容