테이블 형식 환경에서 열 너비 제어

테이블 형식 환경에서 열 너비 제어

오른쪽 열의 텍스트 조각이 왼쪽 열의 텍스트 조각에 더 가깝기를 바랍니다. 동시에, 나는 지금처럼 긴 텍스트를 보기 좋게 수용할 수 있는 테이블을 원합니다. 이 결과를 얻는 한 가지 방법은 왼쪽 열의 너비를 제한하고, 오른쪽 열의 너비를 늘리고, 오른쪽 열의 왼쪽 여백을 왼쪽으로 이동하는 것입니다. 하지만 어떻게 해야 할지 모르겠습니다.

여기 내가 지금까지 얻은 것의 MWE가 있습니다.테이블:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}

\begin{document}

\begin{table}
 \centering
 \begin{tabular}{*{2}{p{.425\linewidth}}}
  \toprule
  first &  second second second second second second second second second second\\
  \midrule
  third & fourth fourth fourth fourth fourth fourth fourth fourth fourth fourth \\
  \bottomrule
 \end{tabular}
\end{table}

\end{document}

당신의 도움을 주셔서 감사합니다.

답변1

질문을 이해하는 한, 시도해 보겠습니다.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}

\begin{document}
\begin{table}
 \centering
 \begin{tabular}{l p{0.5\linewidth}}
  \toprule
  first &  second second second second second second second second second second\\
  \midrule
  third & fourth fourth fourth fourth fourth fourth fourth fourth fourth fourth \\
  \bottomrule
 \end{tabular}
\end{table}
\end{document}

획득하다

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

답변2

@Werner가 이미 의견에서 지적했듯이 서식 지정 목표에 대한 좋은 후보 솔루션은 패키지를 로드하고 . 대신 환경(전체 너비를 로 설정 ) tabularx을 사용하는 것입니다 . 그런 다음 첫 번째 열 사양을 에서 로 변경 하고 , 두 번째 열 사양을 에서 로 변경 합니다 .tabularx\textwidthtabularp{...}lp{...}X

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

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{tabularx} % for "tabularx" env. and "X" column type

\begin{document}

\begin{table}
\begin{tabularx}{\textwidth}{@{} l X @{}}
  \toprule
  first & second second second second second second second 
          second second second second second second second second \\
  \midrule
  third & fourth fourth fourth fourth fourth fourth fourth fourth 
          fourth fourth fourth fourth \\
  \bottomrule
\end{tabularx}
\end{table}

\end{document} 

관련 정보