4

I have seen similar solutions to this kind of problem but they do not seem to work in this kind of table. I can compile this code, but it is annoying to always see the error legend every time I add something new. Does someone have any suggestion that can conserve the style of the table avoid the error?

All suggestions are more than welcome

My code is below, best greetings.

\begin{table}[hbt!]
\caption{ETLs electrical properties}\\
\begin{center}
    
    \begin{tabular}{||c c c c ||} 
        \hline
        Material & HOMO [\si{\electronvolt}] & LUMO [\si{\electronvolt}] & $\mu_e$ [\si{\centi\meter\squared\per\volt\per\second}] \\ [0.5ex] 
        \hline\hline
        ZnO & -7.5 & -4.3 & \num{6.6e-2}   \\ 
        \hline
        TPBi & -6.2 & -2.7 & \num{6.2e-5} \\ [1ex]
        \hline 
    \end{tabular}
\end{center}
\label{tab:ETLs properties}
\end{table}
3
  • 4
    don't add a \\ after the \caption. Apr 28, 2021 at 12:51
  • 1
    It would be helpful if you copy and pasted the error message, instead of attempting to quote it.
    – Teepeemm
    Apr 28, 2021 at 12:51
  • 4
    Unrelated: don't use the center env to center inside a float. It adds additional vertical space. Replace \begin{center} with \centering and delete \end{center}
    – daleif
    Apr 28, 2021 at 12:53

1 Answer 1

3

In addition to removing the detrimental \\ directive after \caption, you may want to apply a few more changes to the table in order to improve its visual appeal -- and thus the likelihood that readers will remember the contents of the table. Among them are, listed in no particular order, the use of better-spaced horizontal rules (courtesy of the booktabs package), the dropping of all vertical rules, automatic math mode for the data columns, the use of the S column type for column with numbers (letting you dispense with \num), the use of macros (such as \ce of the mhchem package) to regularize the typesetting of names of chemical compounds, and a more organized structure of the header material.

The following screenshot provides a before-and-after comparison.

enter image description here

\documentclass{article}
\usepackage{siunitx} % for \si macro
\usepackage{booktabs}        % for use in 2nd table (\toprule, \midrule, \bottomrule)
\usepackage{array}
\newcolumntype{C}{>{$}c<{$}} % ditto (centered column with automatic math mode)
\usepackage{mhchem}          % ditto (for \ce macro)

\begin{document}
\begin{table}[hbt!]
\caption{First version}
\begin{center} 
    \begin{tabular}{||c c c c ||} 
        \hline
        Material & HOMO [\si{\electronvolt}] & LUMO [\si{\electronvolt}] & $\mu_e$ [\si{\centi\meter\squared\per\volt\per\second}] \\ [0.5ex] 
        \hline\hline
        ZnO & -7.5 & -4.3 & \num{6.6e-2}   \\ 
        \hline
        TPBi & -6.2 & -2.7 & \num{6.2e-5} \\ [1ex]
        \hline 
    \end{tabular}
\end{center}
\label{tab:ETLs properties}


\vspace{0.5cm}

\sisetup{per-mode=symbol,tight-spacing}
\caption{Improved version\strut}
\label{tab:ETLs properties}

\centering % use \centering, not \begin{center} and \end{center}
    
    \begin{tabular}{@{} l C C S[table-format=1.1e-1] @{}} 
    \toprule
    Material & {\textrm{HOMO}}  & {\textrm{LUMO}}  & {$\mu_e$}  \\ 
    & {[\si{\electronvolt}]} & {[\si{\electronvolt}]} 
    & {[\si{\centi\meter\squared\per(\volt\second)}]} \\
    \midrule
    \ce{ZnO}  & -7.5 & -4.3 & 6.6e-2  \\ 
    \ce{TPBi} & -6.2 & -2.7 & 6.2e-5  \\
    \bottomrule
    \end{tabular}
\end{table}
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .