如何对齐表格中的两列

如何对齐表格中的两列

我有两列,但右边的列看起来像是垂直居中对齐。如何才能以相同的方式对齐它们?在此处输入图片描述

\documentclass[a4paper]{letter}
\usepackage[a4paper,left=2cm,right=2cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{invoice}

\begin{document}

      \begin{letter}{}
        \opening{Invoice no. 1}

    \begin{tabular}{l  l}

        \begin{tabular}{ll} 
            \textsc{Client Name:} & Dr Matt Osch   \\
            \textsc{Description:} & RNA-seq project - 63 samples \\
                                   &    \\
                                   &    \\
                                   &    \\                                                         
            \textsc{Client's Phone:}     & 88477 \\
            \textsc{email:}     & [email protected] \\
            \textsc{Client's Ref/}\\ \textsc{Order No:}     & \\
        \end{tabular}
        \vline
        \begin{tabular}{ll} 

            \textsc{Date of Service:} & 18/6/2015 \\
            \textsc{CARF Reference:} & MGRF-NGS-65-Q2 \\                                       
            \textsc{CARF Contact:}     & Kevin \\
            \textsc{CARF Contact}\\ \textsc{Extension:}     & 07 4321 7473 \\

        \end{tabular}
    \end{tabular}

  \end{letter}
\end{document}

答案1

您不需要嵌套表格;相反,如果没有外部表格,填充行会更容易。

\documentclass[a4paper]{letter}
\usepackage[a4paper,left=2cm,right=2cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{invoice}

\begin{document}

\begin{letter}{}

\opening{Invoice no. 1}

\noindent % not really necessary
\begin{tabular}[t]{@{}ll}
  \textsc{Client Name:}    & Dr Matt Osch   \\
  \textsc{Description:}    & RNA-seq project - 63 samples \\
  \\
  \\
  \\                                                         
  \textsc{Client's Phone:} & 88477 \\
  \textsc{email:}          & [email protected] \\
  \textsc{Client's Ref/} \\
  \textsc{Order No:} \\
  \end{tabular}
\hfill
\vline
\hfill
\begin{tabular}[t]{ll@{}}
  \textsc{Date of Service:} & 18/6/2015 \\
  \textsc{CARF Reference:}  & MGRF-NGS-65-Q2 \\                                       
  \textsc{CARF Contact:}    & Kevin \\
  \textsc{CARF Contact} \\
  \textsc{Extension:}       & 07 4321 7473 \\
\end{tabular}

\end{letter}

\end{document}

在此处输入图片描述

答案2

这是一个不使用invoice包裹(因为你自己甚至都不使用它):

在此处输入图片描述

\documentclass{article}

\usepackage[margin=15mm]{geometry}

\setlength{\parindent}{0pt}% Just for this example
\begin{document}

Invoice no.~1

\bigskip

\begin{tabular}
   {@{}
    p{\dimexpr.5\linewidth-\tabcolsep} |
    p{\dimexpr.5\linewidth-\tabcolsep}
    @{}}
  \begin{tabular}[t]{l l} 
    \textsc{Client Name:} & Dr Matt Osch   \\
    \textsc{Description:} & RNA-seq project - 63 samples \\
                           &    \\
                           &    \\
                           &    \\                                                         
    \textsc{Client's Phone:}     & 88477 \\
    \textsc{email:}     & [email protected] \\
    \textsc{Client's Ref/}\\ \textsc{Order No:}     & \\
  \end{tabular}
  &
  \begin{tabular}[t]{l l}
    \textsc{Date of Service:} & 18/6/2015 \\
    \textsc{CARF Reference:} & MGRF-NGS-65-Q2 \\                                       
    \textsc{CARF Contact:}     & Kevin \\
    \textsc{CARF Contact}\\ \textsc{Extension:}     & 07 4321 7473 \\
  \end{tabular}
\end{tabular}

\end{document}

答案3

更改代码如下

\documentclass[a4paper]{letter}
\usepackage[a4paper,left=2cm,right=2cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{invoice}
\begin{document}
\begin{letter}{}
\opening{Invoice no. 1}
\begin{tabular}{l  l}
\begin{tabular}{ll|ll} 
\textsc{Client Name:} & Dr Matt Osch & \textsc{Date of Service:} & 18/6/2015 \\  
\textsc{Description:} & RNA-seq project - 63 samples &\textsc{CARF Reference:} & MGRF-NGS-65-Q2 \\ 
& & \textsc{CARF Contact:}     & Kevin \\ 
& &\textsc{CARF Contact}\\ 
\textsc{Extension:}     & 07 4321 7473 \\ 
 &   && \\
\textsc{Client's Phone:}     & 88477 & & \\
\textsc{email:}     & [email protected] &&\\
\textsc{Client's Ref/}&&&\\ 
 \textsc{Order No:}   && &\\
\end{tabular}
\end{tabular}
\end{letter}

\结束{文档}

发票对齐

相关内容