如何将表格宽度设置为文本宽度

如何将表格宽度设置为文本宽度

我怎样才能将其用作width=\linewidth表格?

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

我希望具有与我所使用的图像相同的宽度。

答案1

\textwidth两个建议。我认为中间的那个(有大小)是最糟糕的。上面的表格是您输入的。

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

在此处输入图片描述

相关内容