表格比文本宽

表格比文本宽

我正在尝试生成一个普通表格,但有些列有长行,导致表格超出页边距。如何调整表格宽度

\documentclass[letterpaper,oneside,12pt]{book}

\begin{document}

\begin{table}[htb]
\centering
\vspace{0.5cm}
\caption{\small{Comparison between GPS and INS characteristics}}
    \vspace{0.5cm}
     \renewcommand{\arraystretch}{1.5}
    \begin{tabular}{|c|c|c|}\hline 
                    & GPS                                     & INS                                      \\\hline\hline
                    & Errors are bounded                      & High data rate                           \\
      Advantages    & Long term accuracy                      & Self-contained and independent of jamming\\\hline
                    & Low data rate                           &                                          \\
      Disadvantages & Susceptible to jamming and interference & Errors grow with time                    \\
                    & Fails if no sufficient coverage         & Higher cost for higher quality           \\\hline \hline
  \end{tabular}
\end{table}

\end{document}

答案1

如果你允许多个谎言单元格,那么你可以轻松地适应文本宽度:

\documentclass[letterpaper,oneside,12pt]{book}
    \usepackage{tabularx}
    \begin{document}
\begin{table}[htb]
\centering
\vspace{0.5cm}
\caption{\small{Comparison between GPS and INS characteristics}}
    \vspace{0.5cm}
     \renewcommand{\arraystretch}{1.5}
\begin{tabularx}{\hsize}{|l|X|X|}\hline
                & GPS                   & INS                   \\\hline\hline
                & Errors are bounded    & High data rate        \\
Advantages      & Long term accuracy    & Self-contained and independent of jamming
                                                                \\\hline
                & Low data rate         &                       \\
Disadvantages   & Susceptible to jamming and interference 
                                        & Errors grow with time \\
                & Fails if no sufficient coverage         
                                        & Higher cost for higher quality
                                                                \\\hline \hline
  \end{tabularx}
\end{table}
    \end{document}    

在此处输入图片描述

但是你的表格我会写得不一样:没有垂直线,水平线有不同的厚度......就像这样:

\documentclass[letterpaper,oneside,12pt]{book}
    \usepackage{tabularx,booktabs,makecell,multirow}
    \newcolumntype{L}{>{\raggedright\arraybackslash}X}
    \renewcommand\theadfont{\bfseries}

    \begin{document}
\begin{table}[htb]
\centering
\caption{Comparison between GPS and INS characteristics}
\begin{tabularx}{\hsize}{@{}l
                        >{\setlength\hsize{0.9\hsize}}L
                        >{\setlength\hsize{1.1\hsize}}L@{}}
    \toprule
    & \thead{GPS}           & \thead{INS}                   \\
    \midrule
\multirow{3}{*}{Advantages}
    &   Errors are bounded\newline
        Long term accuracy
            &   High data rate\newline
                Self-contained and independent of jamming   \\
    \cmidrule{2-3}
\multirow{3}{*}{Disadvantages}
    &   Low data rate\newline
        Susceptible to jamming and interference
            &   Errors grow with time\newline
                Fails if no sufficient coverage\newline
                Higher cost for higher quality              \\
    \bottomrule
  \end{tabularx}
\end{table}
    \end{document}    

并得到: 在此处输入图片描述

对于字幕布局(现在不在我的考虑范围内),我将利用字幕包的可能性。

相关内容