如何在表格前显示部分名称?

如何在表格前显示部分名称?

我在想如何在表格前面加上部分名称。我想我可能需要使用float。图 1 中输出的代码

\documentclass{article}
\usepackage{tabularx}
\begin{document}

\section*{Abbreviations}

    \begin{table}
    \begin{tabularx}{\textwidth}{l | l}
    \textit{Abbreviation} & \textit{Definition} \\ \hline
    EHF & Ebola Hemorrhagic Fever (deprecated) \\
    EVD & Ebola Virus Disease (current) \\ 
    IP & Incubation period \\ 
    GP & Glycoprotein \\
    VHF & Viral Hemmorrhagic Fever \\
    \end{tabularx}
    \end{table}

\end{document}

图 1 输出

在此处输入图片描述

操作系统:Debian 8.7

答案1

tabular环境中没有必要必须有或类似的东西table。您的实例不是浮点数,因此不需要table

\documentclass{article}
\usepackage{tabularx}
\begin{document}

\section*{Abbreviations}

\noindent              
\begin{tabularx}{\textwidth}{l | X}
\textit{Abbreviation} & \textit{Definition} \\ \hline
EHF & Ebola Hemorrhagic Fever (depreciated) \\
EVD & Ebola Virus Disease (current) \\
IP & Incubation period \\
GP & Glycoprotein \\
VHF & Viral Hemmorrhagic Fever
\end{tabularx}

\end{document}

请注意,tabularx至少需要一X列。

另一方面,我认为没有tabularx必要。

\documentclass{article}

\begin{document}

\section*{Abbreviations}

\begin{description}

\item[EHF] Ebola Hemorrhagic Fever (depreciated)
\item[EVD] Ebola Virus Disease (current)
\item[IP] Incubation period
\item[GP] Glycoprotein
\item[VHF] Viral Hemmorrhagic Fever

\end{description}

\end{document}

在此处输入图片描述

答案2

如果缩写列表很长,请考虑使用longtable环境而不是tabularxtabular环境。这将允许在需要时自动分页。

在此处输入图片描述

\documentclass{article}
\usepackage{longtable,booktabs}
\begin{document}

\section*{Abbreviations}

\setlength\LTleft{0pt} % left-align rather than center-set the longtable
\begin{longtable}{@{}l p{0.75\textwidth}@{}}
\textit{Abbreviation} & \textit{Definition} \\ 
\midrule
\endhead
EHF & Ebola Hemorrhagic Fever (depreciated) \\
EVD & Ebola Virus Disease (current) \\ 
IP  & Incubation period \\ 
GP  & Glycoprotein \\
VHF & Viral Hemmorrhagic Fever \\
\end{longtable}

\end{document}

答案3

如果您希望它作为浮动环境,那么使用:

\documentclass{article}
\usepackage{tabularx}
\begin{document}

    \section*{Abbreviations}

    \begin{table}[ht]%%%%%%%%%
        \begin{tabularx}{\textwidth}{l | X}
            \textit{Abbreviation} & \textit{Definition} \\ \hline
            EHF & Ebola Hemorrhagic Fever (depreciated) \\
            EVD & Ebola Virus Disease (current) \\ 
            IP & Incubation period \\ 
            GP & Glycoprotein \\
            VHF & Viral Hemmorrhagic Fever \\
        \end{tabularx}
    \end{table}

\end{document}

然而,table在这里不使用环境使用它更有意义。

相关内容