# How to have section name before table?

I am thinking how to have the section name before the table. I think I need to use possibly float. Code which output in Fig. 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}


Fig. 1 Output

OS: Debian 8.7

• Since you don't use that table is a float, it should be enough to comment out \begin{table} and \end{table}. The problem here is that table floats to before the section heading. – StefanH Mar 7 '17 at 7:31
• By the way, you don't even need a tabular for this. If the section title is “Abbreviations” and then a list of acronyms appear, readers will know how to interpret it without telling them about “abbreviation” and “definition”. – egreg Mar 7 '17 at 8:02
• Additionally IMHO you shouldn't use the vertical line in a simple table like this one. – Skillmon likes topanswers.xyz Mar 7 '17 at 8:07
• By the way, "depreciated" should be "deprecated". To depreciate is to lose value over time; to deprecate something is to say that it shouldn't be used any more. – David Richerby Mar 7 '17 at 15:51
• Why not using a package like acro, acronyms or glossaries for such list of abbrevations? – user31729 Mar 7 '17 at 19:15

There is no need that tabular or similar must go in a table environment. Your instance is not a float, so no 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}


Note that tabularx needs at least one X column.

On the other hand, I don't think that tabularx is needed.

\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}


• Maybe you should mention that it's possible to customize the description with enumitem to look like a table. – TeXnician Mar 7 '17 at 8:10
• @TeXnician You did it. ;-) Besides, I don't think it should look like a table. – egreg Mar 7 '17 at 8:10
• Is it ok not to include the heading: abbreviation and definition? Any formal policy here? The last one looks great. I like the simplicity a lot. – Léo Léopold Hertz 준영 Mar 7 '17 at 8:44
• @LéoLéopoldHertz준영 - Indeed, if it's obvious to the reader what the tabular material is all about, the header row may be omitted safely. – Mico Mar 7 '17 at 8:49

If the list of abbreviations is quite long, consider using a longtable environment instead of either a tabularx or a tabular environment. This will allow for automatic page breaks, if and where needed.

\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
EHF & Ebola Hemorrhagic Fever (depreciated) \\
EVD & Ebola Virus Disease (current) \\
IP  & Incubation period \\
GP  & Glycoprotein \\
VHF & Viral Hemmorrhagic Fever \\
\end{longtable}

\end{document}

• Perhaps you should adjust your p{0.75\textwidth} to span the whole line, e.g. with \setbox1\hbox{\textit{Abbreviation}} \newdimen\mywidth \mywidth=\textwidth \advance\mywidth by -\wd1 \advance\mywidth by -2\tabcolsep and then using p{\mywidth} for the column definition. – Skillmon likes topanswers.xyz Mar 7 '17 at 8:39
• @Skillmon - Thanks. I thought about doing just what you suggest, but then I didn't feel sure that's really the best approach. If none of the text strings in the "Definition" column are all that long (and, in particular, don't require a line break), using l instead of p{0.75\textwidth} may be the best solution. Maybe the OP will provide more information about what kind of material will end up being placed in the "Definition" column. – Mico Mar 7 '17 at 8:47
• In this case one could write a macro which checks the width of the entire table while using the l approach and then check whether the width is wider than \textwidth and based on this decide whether to use the l or the p{\mywidth} approach. But this might be over the top :) – Skillmon likes topanswers.xyz Mar 7 '17 at 8:52
• @Skillmon - More thanks. :-) I've noticed that the OP has already "accepted" another answer; we may never find out how desirable it is to make the longtable occupy the full width of the text block. – Mico Mar 7 '17 at 8:53
• Sad but true. While I really would have liked this approach :) I think I'll try to create a versatile macro trying to accomplish this. But my time right now is limitted and I might not be experienced enough yet to create a package like this. – Skillmon likes topanswers.xyz Mar 7 '17 at 8:58

If you want it as a floating environment, then use:

\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}


However, using it without the table environment makes more sense here.

• Confirmed. This works. – Léo Léopold Hertz 준영 Mar 7 '17 at 8:37
• @LéoLéopoldHertz준영 it works most of the time but not necessarily. If TeX thinks it doesn't fit beneath the caption it will still float to the top of a page. You might add an exclamation mark to the [ht] like this [!ht] to make it work even more often. – Skillmon likes topanswers.xyz Mar 7 '17 at 8:42
• With a exclamation mark you have some more changes to the internal setting of floating objects. – user2478 Mar 7 '17 at 8:49