텍스트에 표 맞추기

텍스트에 표 맞추기

표를 만들었는데 다음과 같은 문제가 있습니다. 텍스트 너비에 맞지 않습니다. 나는 \adjustbox와 \tabularx를 사용하여 문제를 해결하려고 시도했지만 둘 다 성공하지 못했습니다(너무 작아서 거의 읽을 수 없게 됩니다). 테이블을 더 보기 좋게 만드는 다른 옵션이 있는지 궁금합니다. 여기에 내 코드와 그 결과를 남겨 둡니다.

\begin{center}
    \begin{tabular}{ccccc}
    \hline
    Verification & Deterministic Versions Comparison & Expected Outcome & True? & Proof \\
    \hline
    1     & Current allocation vs. Optimized & Optimized - Cheaper allocation & Yes & \euro 411,03M vs. \euro 405,82M \\
    
    2     & Optimized vs. Capacity constrained (no UK-EUR) & Optimized - Cheaper allocation & Yes & \euro 405,82M vs.\euro 406,40M \\
    
    3     & Capacity constrained (no UK-EUR) vs. 70\%-30\% volume split by brewery (no UK-EUR) & Capacity constrained (no UK-EUR) - Cheaper allocation & Yes & \euro 406,40M vs. \euro 407,05M \\
  
    4     & 70\%-30\% volume split by brewery (no UK-EUR) vs. Sustainable version (no UK-EUR) & Sustainable version (no UK-EUR) - Lower transportation costs & Yes & \euro 16,79M vs. \euro 14,40M \\
     \hline
    \end{tabular}
      \caption{Verification of the expected outcomes of the versions of the deterministic model.}
    \end{center}

여기에 이미지 설명을 입력하세요

매우 감사합니다!!

답변1

셀의 긴 텍스트를 더 많은 줄로 나누어야 합니다.

\documentclass{article}
\usepackage{geometry}
\usepackage{eurosym}
\usepackage{booktabs, makecell, tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}

\begin{document}
\begin{table}[ht]
\setcellgapes{3pt}
\makegapedcells
\begin{tabularx}{\linewidth}{@{}cLLcL@{}}
\toprule
Ver. & Deterministic Versions Comparison & Expected Outcome & True? & Proof \\
\midrule
1     & Current allocation vs. Optimized & Optimized - Cheaper allocation & Yes & \euro 411,03M vs. \euro 405,82M \\

2     & Optimized vs. Capacity constrained (no UK-EUR) & Optimized - Cheaper allocation & Yes & \euro 405,82M vs.\euro 406,40M \\

3     & Capacity constrained (no UK-EUR) vs. 70\%-30\% volume split by brewery (no UK-EUR) & Capacity constrained (no UK-EUR) - Cheaper allocation & Yes & \euro 406,40M vs. \euro 407,05M \\

4     & 70\%-30\% volume split by brewery (no UK-EUR) vs. Sustainable version (no UK-EUR) & Sustainable version (no UK-EUR) - Lower transportation costs & Yes & \euro 16,79M vs. \euro 14,40M \\
 \bottomrule
\end{tabularx}
  \caption{Verification of the expected outcomes of the versions of the deterministic model. Ver. is abbreviation for Verification.}
\end{table}
\end{document}

여기에 이미지 설명을 입력하세요

답변2

테이블 셀 자체 내에서 줄바꿈을 허용할 수도 있습니다.

게다가 너무 넓은 테이블을 회전할 수도 있습니다.

\documentclass{article}
\usepackage{microtype}
\usepackage{graphicx}%
\usepackage[official]{eurosym}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array}
\usepackage{varwidth}
\newsavebox\tablebox

\newcolumntype{L}[1]{%
  >{%
     \raggedright
     \hsize=#1\hsize
     \begin{varwidth}[t]{\hsize}%
     \narrowragged
     \hyphenpenalty=50
     \exhyphenpenalty=50
     \doublehyphendemerits=50
     \let\newline\\%
     \arraybackslash
     \hspace{0pt}%
     \vrule width 0pt height 1.25\ht\strutbox depth 0pt %
   }%
  X%
  <{%
     \vrule width 0pt height 0pt depth \dimexpr1.25\ht\strutbox-\ht\strutbox+\dp\strutbox
     \end{varwidth}%
   }%
}

\newcolumntype{C}[1]{%
  >{%
     \centering
     \hsize=#1\hsize
     \begin{varwidth}[t]{\hsize}%
     \narrowragged
     \hyphenpenalty=50
     \exhyphenpenalty=50
     \doublehyphendemerits=50
     \let\newline\\%
     \arraybackslash
     \hspace{0pt}%
     \vrule width 0pt height 1.25\ht\strutbox depth 0pt %
   }%
  X%
  <{%
     \vrule width 0pt height 0pt depth \dimexpr1.25\ht\strutbox-\ht\strutbox+\dp\strutbox
     \end{varwidth}%
   }%
}

\fboxsep=-\fboxrule

\begin{document}

\noindent text text text text text text text text text\linebreak

\savebox\tablebox{%
   \begin{tabularx}{\textwidth}{@{}C{.6}L{1.5}L{1.4}C{0.55}L{.95}@{}}%
   \toprule
   Veri\-fi\-ca\-tion&Deterministic Versions Comparison&Expected Outcome&True?&Proof\\
   \midrule
   1 & Current allocation vs. Optimized & Optimized~-- Cheaper allocation & Yes & \euro 411,03M vs. \euro 405,82M \\
   2 & Optimized vs. Capacity constrained (no UK-EUR) & Optimized~-- Cheaper allocation & Yes & \euro 405,82M vs. \euro 406,40M \\
   3 & Capacity constrained (no UK-EUR) vs. 70\%-30\% volume split by brewery (no UK-EUR) & Capacity constrained (no UK-EUR)~-- Cheaper allocation & Yes & \euro 406,40M vs. \euro 407,05M \\
   4 & 70\%-30\% volume split by brewery (no UK-EUR) vs. Sustainable version (no UK-EUR) & Sustainable version (no UK-EUR)~-- Lower transportation costs & Yes & \euro 16,79M vs. \euro 14,40M\\
   \bottomrule
   \end{tabularx}%
}%

\begin{table}
%\centering
%\rotatebox[origin=c]{0}{%
   \begin{minipage}{\wd\tablebox}%
   \usebox{\tablebox}%
   \caption{Verification of the expected outcomes of the versions of the deterministic model.}%
   \end{minipage}%
%}%
\end{table}


\newpage

\noindent text text text text text text text text text\linebreak

\savebox\tablebox{%
   \begin{tabularx}{1.25\textwidth}{@{}C{.5}L{1.9}L{1.45}C{0.35}L{.8}@{}}%
   \toprule
   Veri\-fi\-ca\-tion&Deterministic Versions Comparison&Expected Outcome&True?&Proof\\
   \midrule
   1 & Current allocation vs. Optimized & Optimized~-- Cheaper allocation & Yes & \euro 411,03M vs. \euro 405,82M \\
   2 & Optimized vs. Capacity constrained (no UK-EUR) & Optimized~-- Cheaper allocation & Yes & \euro 405,82M vs. \euro 406,40M \\
   3 & Capacity constrained (no UK-EUR) vs. 70\%-30\% volume split by brewery (no UK-EUR) & Capacity constrained (no UK-EUR)~-- Cheaper allocation & Yes & \euro 406,40M vs. \euro 407,05M \\
   4 & 70\%-30\% volume split by brewery (no UK-EUR) vs. Sustainable version (no UK-EUR) & Sustainable version (no UK-EUR)~-- Lower transportation costs & Yes & \euro 16,79M vs. \euro 14,40M\\
   \bottomrule
   \end{tabularx}%
}%

\begin{table}
\centering
\rotatebox[origin=c]{90}{%
   \begin{minipage}{\wd\tablebox}%
   \usebox{\tablebox}%
   \caption{Verification of the expected outcomes of the versions of the deterministic model.}%
   \end{minipage}%
}%
\end{table}


\end{document}

여기에 이미지 설명을 입력하세요

여기에 이미지 설명을 입력하세요

관련 정보