Minipage 水平错位了 2 个并排的长表格,导致它们重叠,尽管有足够的空间

Minipage 水平错位了 2 个并排的长表格,导致它们重叠,尽管有足够的空间

我习惯minipage将 2 个表格并排放置。我可以让表格清晰易读,但是有没有办法让它们与垂直边距等距并水平对齐?

当我改变参数时,要么表格重叠,要么彼此未对齐,要么右侧表格继续超出页面,导致右侧表格的其余部分不可见。

我需要更改字体大小吗?已经测试过\tiny和 ,但没有成功{5cm}。其他命令根本没有改变字体/表格大小。它只会向右或向左移动。问题出在 吗{0.4textwidth}

编辑1: 有人能说说吗让 minipage 在 A4 页面宽度中占据更多空间吗?

编辑2:必须使用并排表格(因为我要插入很多行)。我有很多长表格,而且没有多少页剩余(所以如果这些表格并排组织,就可以节省空间)。

\documentclass[11pt,a4paper,openright,titlepage,oneside]{book}
    \usepackage{lmodern} \usepackage[T1]{fontenc} \usepackage{boxedminipage}
    \usepackage{geometry} \usepackage{theorem}      \usepackage{fancybox}
    \usepackage{fancyhdr} \usepackage{ifthen}       \usepackage{url}       
    \usepackage{afterpage} \usepackage{color}       \usepackage{colortbl}
    \usepackage{rotating} \usepackage{makeidx}      \usepackage{indentfirst}  
    \usepackage{subfig}   \usepackage{booktabs}     \usepackage{scalefnt}
    \usepackage{ragged2e}  \usepackage[brazilian]{babel} \usepackage{epsfig}         
    \usepackage{epstopdf}   \usepackage{subfigure}  \usepackage{amsfonts} 
    \usepackage{amsmath}    \usepackage{amssymb}  
    \usepackage[thmmarks,amsmath]{ntheorem}
\begin{document}
  \par This is a normal paragraph and my interest is to make the minipage vertical limits to be larger than this paragraph textwidth. Possibly will the tables side-by-side fit in perfectly 
  \begin{table}[!htb]
    \caption{Resultado da clusterização por perdas totais em MT, BT com o algoritmo Ward}
    \label{TabClusterização1a}
    %\setlength{\tabcolsep}{3pt}
    \begin{minipage}{0.30\textwidth}
        \centering
        \begin{tabular}{ccccc}
\toprule   \textbf{Nº} & \multicolumn{2}{c}{\textbf{Clusters agrupados}} 
    & \textbf{SR$^2$} 
    & \textbf{R$^2$}  \\ 
\midrule                
   54 & CEEE-D & EBO & 0.0000 & 1.00 \\ \hline 
   53 & EMS &COSERN & 0.0000 & 1.00 \\ \hline
   52 & CPFL SANTA CRUZ & CNEE & 0.0000 & 1.00 \\ \hline
   51 & DEMEI &EEB & 0.0000 & 1.00 \\ \hline
   50 & EEVP &RGE SUL & 0.0000 & 1.00 \\ 
\bottomrule
  \end{tabular}
\end{minipage} 
\hfill
\begin{minipage}{\linewidth}
    \centering
    \begin{tabular}{c|c|c|c|c}
    27 & LIGHT& CL50 & 0.0001 & 1.00 \\ \cline{1-5} 
    26 & CL34 &ELEKTRO & 0.0001 & 1.00 \\ \cline{1-5}
    25 & CL46&COOPERALIANÇA & 0.0001 & .999 \\ \hline
    24 & EFLUL &CL38 & 0.0001 & .999 \\ \hline
    \end{tabular}
     \end{minipage}
      \end{table}
       \end{document}

答案1

正如评论中提到的,您的表格太宽(即使您使用\tiny字体大小),它们也无法在文档中并行放置。一个合理的解决方案是将它们合并为一个表格,如下所示:

在此处输入图片描述

如您所见,我更喜欢仅具有必要的水平规则的表格,对于这些表格,我使用booktabs包中的规则,对于数字,使用S列类型:

\documentclass[11pt,a4paper,openright,titlepage,oneside]{book}
\usepackage{geometry}
\usepackage{booktabs, makecell, multirow, tabularx}
    \renewcommand\theadfont{\normalsize\bfseries}
    \renewcommand\theadgape{}
\usepackage{siunitx}
\usepackage[skip=1ex]{caption}


\begin{document}
    \begin{table}[ht]
\caption{Resultado da clusterização por perdas totais em MT, BT com o algoritmo Ward}
\label{TabClusterização1a}
\begin{tabularx}{\linewidth}{c X X S[table-format=1.4] S[table-format=1.3]}
    \toprule
\thead[b]{Núm.\\ Clust.}
    & \multicolumn{2}{c}{\thead{Clusters agrupados}}
        &   {\thead{SR$^2$}}    &   {\thead{R$^2$}}     \\ 
    \midrule
54 & CEEE-D             & EBO           & 0.0000 & 1.00 \\  
53 & CPFL PAULISTA      & BANDEIRANTE   & 0.0000 & 1.00 \\  
52 & CPFL SANTA CRUZ    & CNEE          & 0.0000 & 1.00 \\  
51 & DEMEI              & EEB           & 0.0000 & 1.00 \\  
50 & EEVP               & RGE SUL       & 0.0000 & 1.00 \\
    \addlinespace  
27 & LIGHT              & CPFL LESTE PAULISTA   
                                        & 0.0001 & 1.00 \\ 
26 & CL34               & ELEKTRO       & 0.0001 & 1.00 \\ 
25 & CPFL PIRATININGA   & COOPERALIANÇA & 0.0001 & .999 \\ 
24 & EFLUL              & CL38          & 0.0001 & .999 \\
    \bottomrule
\end{tabularx}
    \end{table}
\end{document}

附录: 让我演示一下如何将两个表并联。为此,可以使用以下技巧:

  • 已选择字体大小\footnotesize
  • 规定的表格宽度0.49\linewidth,并在单元格中启用多行文本
  • 单元格文本中仅使用小写字母

在此处输入图片描述

\documentclass[11pt,a4paper,openright,titlepage,oneside]{book}
\usepackage{geometry}
\usepackage{booktabs, makecell, multirow, tabularx}
    \renewcommand\theadfont{\bfseries}
    \renewcommand\theadgape{}
    \newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{siunitx}
\usepackage[skip=1ex]{caption}

\usepackage{lipsum}

\begin{document}
\lipsum[1]
    \begin{table}[ht]
    \footnotesize
    \setlength\tabcolsep{3pt}
\caption{Resultado da clusterização por perdas totais em MT, BT com o algoritmo Ward}
\label{TabClusterização1a}
\begin{tabularx}{0.49\linewidth}[t]{@{}c LL S[table-format=1.4] S[table-format=1.3]@{}}
    \toprule
\thead[b]{N. C.}
    & \multicolumn{2}{c}{\thead{Clusters agrupados}}
        &   {\thead{SR$^2$}}    &   {\thead{R$^2$}}     \\
    \midrule
54 & ceee-d             & ebo           & 0.0000 & 1.00 \\
53 & cpfl paulista      & bandeirante   & 0.0000 & 1.00 \\
52 & cpfl santa cruz    & cnee          & 0.0000 & 1.00 \\
51 & demei              & eeb           & 0.0000 & 1.00 \\
50 & eevp               & rge sul       & 0.0000 & 1.00 \\
    \bottomrule
\end{tabularx}
\,%
\begin{tabularx}{0.49\linewidth}[t]{@{}c LL S[table-format=1.4] S[table-format=1.3]@{}}
    \toprule
\thead[b]{N. C.}
    & \multicolumn{2}{c}{\thead{Clusters agrupados}}
        &   {\thead{SR$^2$}}    &   {\thead{R$^2$}}     \\
    \midrule
27 & light              & cpfl leste paulista
                                        & 0.0001 & 1.00 \\
26 & cl34               & elektro       & 0.0001 & 1.00 \\
25 & cpfl piratininga   & cooperaliança & 0.0001 & .999 \\
24 & eflul              & cl38          & 0.0001 & .999 \\
    \bottomrule
\end{tabularx}
    \end{table}
\end{document}

答案2

您可以使用adjustbox,但我建议您不要将它们并排放置,考虑一下您的远见读者。

\documentclass[11pt,a4paper,openright,titlepage,oneside]{book}
    \usepackage{lmodern} \usepackage[T1]{fontenc} \usepackage{boxedminipage}
    \usepackage{geometry} %\usepackage{theorem} you also add new theorem
    \usepackage{fancybox}
    \usepackage{fancyhdr} \usepackage{ifthen}       \usepackage{url}       
    \usepackage{afterpage} \usepackage{color}       \usepackage{colortbl}
    \usepackage{rotating} \usepackage{makeidx}      \usepackage{indentfirst}  
    %\usepackage{subfig} you also add subfigure
    \usepackage{adjustbox}% added
    \usepackage{graphicx}% added
    \usepackage{caption}% added
    \usepackage{multirow}% added
    \usepackage{booktabs}     \usepackage{scalefnt}
    \usepackage{ragged2e}  \usepackage[brazilian]{babel} \usepackage{epsfig}         
    \usepackage{epstopdf}   \usepackage{subfigure}  \usepackage{amsfonts} 
    \usepackage{amsmath}    \usepackage{amssymb}  \usepackage[thmmarks,amsmath]{ntheorem}
\begin{document}
Do you want something like Table \ref{TabClusteriz}?% I would not use special char in labels

Isn't Table \ref{mytab} much more readable?

 \begin{table}[tbp]\centering
 \caption{\label{TabClusteriz}Resultado da clusterização por perdas totais em MT, BT com o algoritmo Ward}  
  \begin{adjustbox}{max width=\textwidth}
     \begin{tabular}{c|c|c|c|c}
       \textbf{Número} & \multicolumn{2}{c|}{\textbf{Clusters agrupados}} 
        & \textbf{SR$^2$} 
        & \textbf{R$^2$}  \\ \cline{2-3} 
        \textbf{de Clusters} &&&&\\ \hline
        54 & CEEE-D & EBO & 0.0000 & 1.00                 \\ \hline 
        53 & CPFL PAULISTA & BANDEIRANTE & 0.0000 & 1.00  \\ \hline
        52 & CPFL SANTA CRUZ & CNEE & 0.0000 & 1.00       \\ \hline 
        51 & DEMEI &EEB & 0.0000 & 1.00                   \\ \hline 
        50 & EEVP &RGE SUL & 0.0000 & 1.00                 \\ \hline
       \end{tabular}

    \begin{tabular}[t]{c|c|c|c|c}
        27 & LIGHT& CPFL LESTE PAULISTA & 0.0001 & 1.00     \\ \cline{1-5} 
        26 & CL34 &ELEKTRO & 0.0001 & 1.00                  \\ \cline{1-5}
        25 & CPFL PIRATININGA & COOPERALIANÇA & 0.0001 & .999 \\ \hline
        24 & EFLUL &CL38 & 0.0001 & .999                     \\ \hline
       \end{tabular}
    \end{adjustbox}
\end{table}
\begin{table}[tbp]\centering
 \caption{\label{mytab}Resultado da clusterização por perdas totais em MT, BT com o algoritmo Ward}     \begin{tabular}{ccccc}
    \toprule
       \textbf{Número} & \multicolumn{2}{c}{\multirow{2}{*}{\textbf{Clusters agrupados}}} 
        & \multirow{2}{*}{\textbf{SR$^2$}} 
        & \multirow{2}{*}{\textbf{R$^2$}}  \\ 
        \textbf{de Clusters} \\ 
        \midrule
        54 & CEEE-D & EBO & 0.0000 & 1.00                 \\  
        53 & CPFL PAULISTA & BANDEIRANTE & 0.0000 & 1.00  \\ 
        52 & CPFL SANTA CRUZ & CNEE & 0.0000 & 1.00       \\  
        51 & DEMEI &EEB & 0.0000 & 1.00                   \\ 
        50 & EEVP &RGE SUL & 0.0000 & 1.00                 \\ 
        27 & LIGHT& CPFL LESTE PAULISTA & 0.0001 & 1.00     \\  
        26 & CL34 &ELEKTRO & 0.0001 & 1.00                  \\ 
        25 & CPFL PIRATININGA & COOPERALIANÇA & 0.0001 & .999 \\ 
        24 & EFLUL &CL38 & 0.0001 & .999                     \\ 
        \bottomrule
       \end{tabular}
\end{table}
\end{document}

在此处输入图片描述

答案3

您可以使用以下方法使它们适合\tiny

示例输出

\documentclass[11pt,a4paper,openright,titlepage,oneside]{book}

\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{boxedminipage}
\usepackage{geometry}
\usepackage{fancybox}
\usepackage{fancyhdr}
\usepackage{ifthen}
\usepackage{url}
\usepackage{afterpage}
\usepackage{color}
\usepackage{colortbl}
\usepackage{rotating}
\usepackage{makeidx}
\usepackage{indentfirst}
\usepackage{subfig}
\usepackage{booktabs}
\usepackage{scalefnt}
\usepackage{ragged2e}
\usepackage[brazilian]{babel}
\usepackage{epsfig}
\usepackage{epstopdf}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[thmmarks,amsmath]{ntheorem}
\usepackage{theorem}

\begin{document}
This is a normal paragraph and my interest is to make the minipage
vertical limits to be larger than this paragraph textwidth. Possibly
will the tables side-by-side fit in perfectly
\begin{table}
  \caption{Resultado da clusterização por perdas totais em MT, BT com
  o algoritmo Ward}
  \label{TabClusterização1a}
  \begin{minipage}{0.5\textwidth}
    \tiny \centering
    \begin{tabular}{ccccc}
      \toprule   \textbf{Nº} & \multicolumn{2}{c}{\textbf{Clusters agrupados}}
      & \textbf{SR$^2$}
      & \textbf{R$^2$}  \\
      \midrule
      54 & CEEE-D & EBO & 0.0000 & 1.00 \\ \hline
      53 & EMS &COSERN & 0.0000 & 1.00 \\ \hline
      52 & CPFL SANTA CRUZ & CNEE & 0.0000 & 1.00 \\ \hline
      51 & DEMEI &EEB & 0.0000 & 1.00 \\ \hline
      50 & EEVP &RGE SUL & 0.0000 & 1.00 \\
      \bottomrule
    \end{tabular}
  \end{minipage}
  \hfill
  \begin{minipage}{0.46\linewidth}
    \tiny
    \centering
    \begin{tabular}{c|c|c|c|c}
      27 & LIGHT& CL50 & 0.0001 & 1.00 \\ \hline
      26 & CL34 &ELEKTRO & 0.0001 & 1.00 \\ \hline
      25 & CL46&COOPERALIANÇA & 0.0001 & .999 \\ \hline
      24 & EFLUL &CL38 & 0.0001 & .999 \\ \hline
    \end{tabular}
  \end{minipage}
\end{table}

\end{document}

请注意,minipage命令不会调整任何表格的大小,它只会使指定的包含框为,而太宽的材料会突出。检查日志文件会提供有关材料溢出程度的信息,以“框满警告”的形式显示。宽度的总和minipages应小于\linewidth。在上面的代码中,我已将它们设置得足够大,因此不会出现框满警告。

相关内容