在 Latex 中对齐表格

在 Latex 中对齐表格

我在 Latex 中有一个表格,我想将文本左对齐。这是表格源代码。任何帮助都将不胜感激。问候

\begin{table}[th] \centering
\caption{Packages used in the decoder implementation.}
\begin{tabular}{ccl}
\toprule
\textbf{Package} & \textbf{Brief Description}\\
\midrule
 branch\_distance & This file calculates the branch distance using $d_E$.\\
  acs & Add, compare and select functionality is implemented in this source 
  file.\\
  ram\_ctrl & The memory management controller is implemented in this 
  file.\\
   traceback & Traceback functionality is implemented in this source file.\\
  pkg\_trellis & It contains trellis helper function, which constructs the 
  trellis structure.\\
  reorder & For reordering the decoded bits, a simple LIFO module is 
  required, which is implemented in this source file.\\
  dec\_viterbi & This is the top-level module of the decoder IP core.\\ 
  generic\_sp\_ram & Implementation Generic single port RAM.\\ 
  \bottomrule
  \end{tabular}
  \label{tab.source}
  \end{table} 

答案1

编辑: 被认为是 伯纳德使用ragged2e包进行注释和换行。

您的表格似乎对于可用的文本宽度来说太宽了。一种可能的解决方案是使用tabularx表格环境并强制将单元格中的长文本分成多行:

\documentclass{article}
\usepackage{ragged2e}
\usepackage{booktabs, tabularx}
\newcolumntype{L}{>{\RaggedRight}X}
\usepackage[skip=1ex]{caption}

    \begin{document}
\begin{table}[th]
\centering
\renewcommand\arraystretch{1.3}
    \caption{Packages used in the decoder implementation.}
\begin{tabularx}{\linewidth}{l L}
    \toprule
\textbf{Package}    &   \textbf{Brief Description}  \\
    \midrule
branch\_distance    &   This file calculates the branch distance using $d_E$.\\
acs                 &   Add, compare and select functionality is implemented
                        in this source file.        \\
ram\_ctrl           &   The memory management controller is implemented
                        in this file.               \\
traceback           &   Traceback functionality is implemented in this source file.\\
pkg\_trellis        &   It contains trellis helper function, 
                        which constructs the
trellis structure.\\
reorder             &   For reordering the decoded bits, 
                        a simple LIFO module is required, 
                        which is implemented in this source file.\\
dec\_viterbi        &   This is the top-level module of the decoder IP core.\\
generic\_sp\_ram    &   Implementation Generic single port RAM.\\
  \bottomrule
\end{tabularx}
    \label{tab.source}
\end{table}
    \end{document}

在此处输入图片描述

相关内容