无法使文本左对齐和右对齐

无法使文本左对齐和右对齐

我正在尝试将页面上的“发件人”和“收件人”地址左对齐和右对齐。这是我的 LaTeX:

%tutorial @: https://www.overleaf.com/20012832vhybmwjdyjqt#/73357884/

\documentclass[12pt]{article}

\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[colorinlistoftodos]{todonotes}

\pagestyle{fancy}
\fancyfoot{}
\fancyfoot[LE,RO]{\thepage}           % page number in "outer" position of footer line
\fancyfoot[LO]{FOR OFFICIAL USE ONLY}
\fancyhead{}
\fancyhead[RO]{Town1 to Town2}

\setcounter{secnumdepth}{1} %turns off numbering of sections

\begin{document}

\begin{titlepage}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\center

\textsc{\LARGE Company Corp.}\\[1.5cm]
\textsc{\Large Project Number: 1}\\[0.5cm]
\textsc{\large For Official Use Only}\\[0.5cm]

\HRule \\[0.4cm]
{ \huge \bfseries Shipping Report}\\[0.4cm]
\HRule \\[1cm]

\begin{minipage}{1\textwidth}
\begin{flushleft} \large
\emph{From}\\
\textsc{Company}\\
First Name\\
Street\\
Town
\end{flushleft}
\end{minipage}
\hfill
\begin{minipage}{1\textwidth}
\begin{flushright} \large
\emph{To} \\
\textsc{Attn: Guy}\\
Street\\
Town\\
\end{flushright}
\end{minipage}\\[1cm]

\end{titlepage}

结果如下:

From
First Name
Street 
Town   
                       To
                       Attn: Guy
                       Street
                       Town

我希望 From 和 To 在同一行上左对齐,To 和 From 右对齐,而不是像这里看到的一样交错。我做错了什么?

答案1

你是指这样的吗?

\documentclass{article} 
\usepackage[pass,showframe]{geometry}
\usepackage[usestackEOL]{stackengine}
\begin{document} 
{\large\noindent\Longunderstack[l]{
\emph{From}\\
\textsc{Company}\\
First Name\\
Street\\
Town}\hfill\Longunderstack[r]{
\emph{To} \\
\textsc{Attn: Guy}\\
Street\\
Town\\
}}\vspace{\baselineskip}

Normalsize text
\end{document}

在此处输入图片描述

答案2

这就是你需要的吗?

在此处输入图片描述

\documentclass{article}
\begin{document}

\begin{minipage}{0.5\linewidth}
 \large
\emph{From}\\
\textsc{Company}\\
First Name\\
Street\\
Town
\end{minipage}
\hfill
\begin{minipage}{0.5\linewidth}
  \begin{flushright}
 \large
\emph{To} \\
\textsc{Attn: Guy}\\
Street\\
Town\\
\end{flushright}

\end{minipage}\\[1cm]
\end{document}

相关内容