1

How can I use width=\linewidth for a table?

\begin{table}[htb]
\centering
\begin{tabular}{|l|l|l|l|l|}
\hline
\textbf{Model} & \textbf{a} & \textbf{b} & \textbf{c}  \\ \hline
\textbf{R}    & \SI{}{\ohm}                 & \SI{22.244}{\ohm}             & \SI{24.553}{\ohm}                    \\ \hline
\textbf{C}   & \SI{6}{\femto\farad}       & \SI{4}{\femto\farad}      & \SI{4}{\femto\farad}             \\ \hline
\textbf{L}    & \SI{1}{\milli\henry}      & \SI{2}{\milli\henry}     & \SI{2}{\milli\henry}            \\ \hline
\textbf{C}   & \SI{1}{\pico\farad}        & \SI{1}{\pico\farad}        & \SI{1}{\pico\farad}               \\ \hline
\textbf{Q}     &                                &                               &                                      \\ \hline
\end{tabular}
\caption {The quartz crystals tested for this design}
\label{tab:elisa0_models}
\end{table}

I would like to have the same width like the images that I am using.

  • See tabularx package. – Steven B. Segletes Aug 27 at 12:42
  • As Steven suggests tabularx one of the better option, and may use \begin{tabular*}{\textwidth or \columnwidth} also ... – MadyYuvi Aug 27 at 12:46
4

Two proposals. The middle one (with \textwidth size) is the worst, in my opinion. The top table is your input.

\documentclass{article}
\usepackage{siunitx}
\usepackage{tabularx} % second example
\usepackage{booktabs} % third example

% see https://tex.stackexchange.com/a/505620/4427
\DeclareSIPrefix{\femto}{f\/}{-15} % \/ seems better

\begin{document}

\centering

\begin{tabular}{|l|l|l|l|l|}
\hline
\textbf{Model} & \textbf{a}           & \textbf{b}           & \textbf{c}           \\
\hline
\textbf{R}     & \si{\ohm}            & \SI{22.244}{\ohm}    & \SI{24.553}{\ohm}    \\
\hline
\textbf{C}     & \SI{6}{\femto\farad} & \SI{4}{\femto\farad} & \SI{4}{\femto\farad} \\
\hline
\textbf{L}     & \SI{1}{\milli\henry} & \SI{2}{\milli\henry} & \SI{2}{\milli\henry} \\
\hline
\textbf{C}     & \SI{1}{\pico\farad}  & \SI{1}{\pico\farad}  & \SI{1}{\pico\farad}  \\
\hline
\textbf{Q}     &                      &                      &                      \\
\hline
\end{tabular}

\bigskip

\begin{tabularx}{\textwidth}{|*{5}{X|}}
\hline
\textbf{Model} & \textbf{a}           & \textbf{b}           & \textbf{c}           \\
\hline
\textbf{R}     & \si{\ohm}            & \SI{22.244}{\ohm}    & \SI{24.553}{\ohm}    \\
\hline
\textbf{C}     & \SI{6}{\femto\farad} & \SI{4}{\femto\farad} & \SI{4}{\femto\farad} \\
\hline
\textbf{L}     & \SI{1}{\milli\henry} & \SI{2}{\milli\henry} & \SI{2}{\milli\henry} \\
\hline
\textbf{C}     & \SI{1}{\pico\farad}  & \SI{1}{\pico\farad}  & \SI{1}{\pico\farad}  \\
\hline
\textbf{Q}     &                      &                      &                      \\
\hline
\end{tabularx}

\bigskip

\begin{tabular}{@{}*{5}{l}@{}}
\toprule
\textbf{Model} &
  \multicolumn{1}{c}{\textbf{a}} &
  \multicolumn{1}{c}{\textbf{b}} &
  \multicolumn{1}{c}{\textbf{c}} \\
\midrule
\textbf{R}     & \si{\ohm}            & \SI{22.244}{\ohm}    & \SI{24.553}{\ohm}    \\
\textbf{C}     & \SI{6}{\femto\farad} & \SI{4}{\femto\farad} & \SI{4}{\femto\farad} \\
\textbf{L}     & \SI{1}{\milli\henry} & \SI{2}{\milli\henry} & \SI{2}{\milli\henry} \\
\textbf{C}     & \SI{1}{\pico\farad}  & \SI{1}{\pico\farad}  & \SI{1}{\pico\farad}  \\
\textbf{Q}     &                      &                      &                      \\
\bottomrule
\end{tabular}

\end{document}

enter image description here

  • 1
    I like that kind of short overview ^^ – Black Mild Aug 27 at 15:02
  • 1
    Maybe one could include the unit into the first colum in order to avoid repetition – leandriis Aug 27 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.