LATEX 表格不对齐

LATEX 表格不对齐
\documentclass[11pt]{article}
\usepackage[margin=3cm]{geometry}
\titleformat{\section}         
  {\scshape\raggedright} 
   \usepackage{tabularx}
\begin{document}

\section*{TEST}
\begin{tabular}{!{\hskip .0in}L!{\hskip .55in}R}
2000 & Text\\
2004$-$2005 & More Text Here\\
\end{tabular}
\end{document}

在此处输入图片描述

\documentclass[11pt]{article}
\usepackage[margin=3cm]{geometry}
\usepackage{tabularx}

\begin{document}

\section*{Section 1}
\begin{tabular}{>{}l<{} !{\hspace{0.1in}} l}
Year$-$Now & Data 1\\
& Data 2 may be different in length and may be much longer in fact\\
Year$-$Now & Data 3 may vary in length\\
& Data 4 even if it is longer\\
\end{tabular}


\section*{Section 2}
\begin{tabular}{>{}l<{} !{\hspace{0.1in}} l}
Year & {This text is much longer}\\
 & this text is also greater in length as you can see\\
\\
Year & {More information here}\\
\end{tabular}

\end{document}

在此处输入图片描述

答案1

您似乎正在从以下示例中寻找一个:

\documentclass[11pt]{article}
\usepackage[margin=3cm]{geometry}
\usepackage{tabularx}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}

\section*{TEST}

\begin{tabularx}{\linewidth}{>{$}l<{$} !{\hspace{0.55in}} >{\raggedleft\arraybackslash}X}
2000        & Text\\
2004-2005   & More Text Here\\
\end{tabularx}

\medskip
or 
\medskip

\noindent%
\begin{tabularx}{\linewidth}{@{} >{$}l<{$} !{\hspace{0.55in}} >{\raggedleft\arraybackslash}X @{}}
2000        & Text\\
2004-2005   & More Text Here\\
\end{tabularx}

\end{document}

在此处输入图片描述

如您所见,和的定义使用了表格和列类型,而不是和。tabular由于的宽度规定为文本宽度,因此表格宽度是从左文本边框到右文本边框。LR\tabularxXtabularx

附录:通过编辑您的问题,您实际上提出了新的问题......无论如何,解决方案可能是以下内容(我猜):

\documentclass[11pt]{article}
\usepackage[margin=3cm]{geometry}
\usepackage{ragged2e}
\usepackage{booktabs, tabularx}
\newcolumntype{L}{>{\RaggedRight}X}

\begin{document}

\section*{Section 1}
\begin{tabularx}{\linewidth}{p{5em} !{\hspace{0.1in}} L}
Year -- Now & Data 1\\
            & Data 2 may be different in length and may be much longer in fact\\
    \addlinespace
Year -- Now & Data 3 may vary in length \\
            & Data 4 are very long, so and they may be longer than column width. Consequently in such a case they will be broken into two or more lines\\
   \addlinespace
Year -- Now & Data 5 may vary in length \\
            & Data 4 even if it is longer and it may be broken into many lines\\
\end{tabularx}


\section*{Section 2}
\begin{tabularx}{\linewidth}{p{5em} !{\hspace{0.1in}} L}
Year        & This text is much longer  \\      
            & Text in the second row is very long, consequently it is broken into many lines\\
    \addlinespace
2020 -- 2020    & More information here\\
\end{tabularx}

\end{document}

在此处输入图片描述

答案2

请尝试以下操作:

\begin{tabular}{l p{3em} r}
    2000 && Text\\
    2004$-$2005 && More Text Here\\
\end{tabular}

p只需调整括号后的间距值即可获得所需的结果。

                  在此处输入图片描述 在此处输入图片描述

相关内容