强制长表宽度精确地位于文本宽度之内

强制长表宽度精确地位于文本宽度之内

我一直在寻找这个问题的解决方案,但我只找到了使用smallfootnotesize调整表格字体字母或\setlength\tabcolsep调整列宽的解决方案。但这些解决方案不能自动将表格宽度调整到文本宽度,也不\resizebox适用于长表环境。那么,我该怎么办呢?

\resizebox观察:为了便于宽度比较,我还在表格环境中放置了一个写有表格。

   \documentclass[12pt,a4paper]{article}
   \usepackage[utf8]{inputenc}
   \usepackage[brazilian]{babel}
   \usepackage{float}
   \usepackage{graphicx}
   \usepackage[justification=centering]{caption}
   \usepackage[T1]{fontenc} %CODE
   \usepackage{uarial}% FOR
   \renewcommand{\familydefault}{\sfdefault}% ARIAL FONT
   \usepackage{longtable}
   \usepackage[top=2cm,left=2cm,right=2cm,bottom=2cm]{geometry}
   \parindent=1.5cm
   \newcommand{\specialcell}[2][c]{%
   \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}
   \usepackage{hyperref}
    \begin{document}
        \newpage
         \begin{table}[H]    
         \begin{center}  

        \caption{Lista dos amortecimentos mínimos para cada ponto de operação em relação diferentes sistemas de controle operando}
        \label{zetas}
        \vspace{-0.2cm}
        \resizebox{\columnwidth}{!}{%
            \begin{tabular}{|c|c|c|c|}
                \hline  \specialcell{ Condição \\ operativa} & \specialcell{ PSSs locais\\ \centering{$\zeta_{min} (\%) $}}  & \specialcell{ PSSs locais + PSS central \\ \centering{$\zeta_{min} (\%) $}}   & \specialcell{ PSSs locais + PSS central ordem reduzida\\  \centering{$\zeta_{min} (\%) $} } \\ 
                \hline Ponto 1& 15.59  & 40.80 & 28.19 \\ 
                \hline Ponto 2& 15.59 & 38.83 &  27.98 \\ 
                \hline Ponto 3& 15.63 & 41.48 &  27.71 \\ 
                \hline Ponto 4& 15.77 & 36.19 &  29.06\\ 
                \hline Ponto 5& 15.71 & 41.47 &  27.26\\ 
                \hline Ponto 6& 15.92 & 36.70 &  27.57\\ 
                \hline Ponto 7& 16.13 & 40.18 &  28.34\\ 
                \hline Ponto 8& 16.21 & 35.80 &  27.34\\ 
                \hline Ponto 9& 15.75 & 40.95 &  27.08\\ 
                \hline Ponto 10& 15.89& 35.21 &  29.18\\ 
                \hline Ponto 11& 16.20 & 33.60 & 29.30 \\ 
                \hline Ponto 12& 15.81 & 40.36 & 26.84 \\ 
                \hline Ponto 13& 16.89 & 34.40 & 26.87 \\ 
                \hline Ponto 14& 18.16 & 43.44 & 34.15 \\ 
                \hline Ponto 15& 23.74 & 37.72 & 30.89 \\ 
                \hline Ponto 16& 17.10 & 38.15 & 28.71 \\ 
                \hline Ponto 17& 19.51 & 30.68 & 25.64 \\ 
                \hline Ponto 18& 15.53 & 26.82 & 23.00 \\ 
                \hline Ponto 19& 12.56 & 34.74 & 26.83 \\ 
                \hline Ponto 20& 19.33 & 37.94 & 31.92 \\ 
                \hline Ponto 21& 20.07 & 37.21 & 35.49 \\ 
                \hline Ponto 22& 15.62 & 38.39 & 28.66 \\ 
                \hline Ponto 23& 15.67 & 37.94 & 25.93 \\ 
                \hline Ponto 24& 15.72 & 37.75 & 25.61 \\ 
                \hline Ponto 25& 15.76 & 37.99 & 25.41 \\ 
                \hline Ponto 26& 15.69 & 31.47 & 26.37 \\ 
                \hline Ponto 27& 17.35 & 29.22 & 25.28 \\ 
                \hline 
            \end{tabular} 
            %
        }   \end{center}

    \end{table} \vspace{-1.4cm}
    \footnotesize
\begin{longtable}{|c|c|c|c|}    
        \caption{Lista dos amortecimentos mínimos para cada ponto de operação em relação diferentes sistemas de controle operando}
        \label{table1}\\
            \hline   \specialcell{ Condição \\ operativa} & \specialcell{ PSSs locais\\ \centering{$\zeta_{min} (\%) $}}  & \specialcell{ PSSs locais + PSS central \\ \centering{$\zeta_{min} (\%) $}}   & \specialcell{ PSSs locais + PSS central ordem reduzida\\  \centering{$\zeta_{min} (\%) $} } \\ 
            \hline Ponto 1& 15.59  & 40.80 & 28.19 \\ 
            \hline Ponto 2& 15.59 & 38.83 &  27.98 \\ 
            \hline Ponto 3& 15.63 & 41.48 &  27.71 \\ 
            \hline Ponto 4& 15.77 & 36.19 &  29.06\\ 
            \hline Ponto 5& 15.71 & 41.47 &  27.26\\ 
            \hline Ponto 6& 15.92 & 36.70 &  27.57\\ 
            \hline Ponto 7& 16.13 & 40.18 &  28.34\\ 
            \hline Ponto 8& 16.21 & 35.80 &  27.34\\ 
            \hline Ponto 9& 15.75 & 40.95 &  27.08\\ 
            \hline Ponto 10& 15.89& 35.21 &  29.18\\ 
            \hline Ponto 11& 16.20 & 33.60 & 29.30 \\ 
            \hline Ponto 12& 15.81 & 40.36 & 26.84 \\ 
            \hline Ponto 13& 16.89 & 34.40 & 26.87 \\ 
            \hline Ponto 14& 18.16 & 43.44 & 34.15 \\ 
            \hline Ponto 15& 23.74 & 37.72 & 30.89 \\ 
            \hline Ponto 16& 17.10 & 38.15 & 28.71 \\ 
            \hline Ponto 17& 19.51 & 30.68 & 25.64 \\ 
            \hline Ponto 18& 15.53 & 26.82 & 23.00 \\ 
            \hline Ponto 19& 12.56 & 34.74 & 26.83 \\ 
            \hline Ponto 20& 19.33 & 37.94 & 31.92 \\ 
            \hline Ponto 21& 20.07 & 37.21 & 35.49 \\ 
            \hline Ponto 22& 15.62 & 38.39 & 28.66 \\ 
            \hline Ponto 23& 15.67 & 37.94 & 25.93 \\ 
            \hline Ponto 24& 15.72 & 37.75 & 25.61 \\ 
            \hline Ponto 25& 15.76 & 37.99 & 25.41 \\ 
            \hline Ponto 26& 15.69 & 31.47 & 26.37 \\ 
            \hline Ponto 27& 17.35 & 29.22 & 25.28 \\ 
            \hline 
\end{longtable} 
 \end{document}

答案1

一些建议:

  • 切勿\resizebox用于表格——除非您愿意冒险在文档的文本和表格部分之间以及从一个表格到另一个表格时造成字体大小发生重大变化。

  • 相反,为表头提供更多结构,例如通过精心选择的换行符。这样,表的整体宽度就不会超出\textwidth范围。

  • 务必通过省略所有垂直线和大多数水平线来使表格看起来更“开放”。对于剩余的几条水平线,请勿使用\hline。相反,请使用包的线条绘制宏booktabs来生成间距合适的线条。

  • 如果您仍然希望环境的宽度longtable等于文本块的宽度,请使用 longtable 包用户指南第 7 页中说明的方法;另请参见下文。

在此处输入图片描述

   \documentclass[12pt,a4paper]{article}
   \usepackage[utf8]{inputenc}
   \usepackage[brazilian]{babel}
   \usepackage{booktabs}
   \usepackage{graphicx}
   \usepackage[justification=centering]{caption}
   \usepackage[T1]{fontenc} %CODE
   \usepackage{helvet}% FOR
   \renewcommand{\familydefault}{\sfdefault}% ARIAL FONT
   \usepackage{longtable}
   \usepackage[margin=2cm]{geometry}
   \parindent=1.5cm
   \newcommand{\specialcell}[2][t]{%
      \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}
   \usepackage{hyperref}
   \begin{document}

\setlength\LTleft{0pt} % see p. 7 of longtable package user guide
\setlength\LTright{0pt}
\begin{longtable}{@{} l @{\extracolsep{\fill}} ccc @{}}    
\caption{Lista dos amortecimentos mínimos para cada ponto de operação em relação diferentes sistemas de controle operando}
\label{table1}\\
\toprule
\specialcell{Condição \\ operativa} & 
\specialcell{PSSs locais\\ \\ $\zeta_{\min}$ (\%) }  & 
\specialcell{PSSs locais + \\ PSS central \\ $\zeta_{\min}$ (\%) }   & 
\specialcell{PSSs locais + \\ PSS central ordem reduzida \\ $\zeta_{\min}$ (\%) } \\ 
\midrule
\endhead
\bottomrule
\endfoot
Ponto 1& 15.59  & 40.80 & 28.19 \\ 
Ponto 2& 15.59 & 38.83 &  27.98 \\ 
Ponto 3& 15.63 & 41.48 &  27.71 \\ 
Ponto 4& 15.77 & 36.19 &  29.06\\ 
Ponto 5& 15.71 & 41.47 &  27.26\\ \addlinespace
Ponto 6& 15.92 & 36.70 &  27.57\\ 
Ponto 7& 16.13 & 40.18 &  28.34\\ 
Ponto 8& 16.21 & 35.80 &  27.34\\ 
Ponto 9& 15.75 & 40.95 &  27.08\\ 
Ponto 10& 15.89& 35.21 &  29.18\\ \addlinespace
Ponto 11& 16.20 & 33.60 & 29.30 \\ 
Ponto 12& 15.81 & 40.36 & 26.84 \\ 
Ponto 13& 16.89 & 34.40 & 26.87 \\ 
Ponto 14& 18.16 & 43.44 & 34.15 \\ 
Ponto 15& 23.74 & 37.72 & 30.89 \\ \addlinespace
Ponto 16& 17.10 & 38.15 & 28.71 \\ 
Ponto 17& 19.51 & 30.68 & 25.64 \\ 
Ponto 18& 15.53 & 26.82 & 23.00 \\ 
Ponto 19& 12.56 & 34.74 & 26.83 \\ 
Ponto 20& 19.33 & 37.94 & 31.92 \\ \addlinespace
Ponto 21& 20.07 & 37.21 & 35.49 \\ 
Ponto 22& 15.62 & 38.39 & 28.66 \\ 
Ponto 23& 15.67 & 37.94 & 25.93 \\ 
Ponto 24& 15.72 & 37.75 & 25.61 \\ 
Ponto 25& 15.76 & 37.99 & 25.41 \\ \addlinespace
Ponto 26& 15.69 & 31.47 & 26.37 \\ 
Ponto 27& 17.35 & 29.22 & 25.28 \\ 
\end{longtable} 
\end{document}

相关内容