7열 테이블 형식(x)이 지정된 것보다 넓은 이유는 무엇입니까?

7열 테이블 형식(x)이 지정된 것보다 넓은 이유는 무엇입니까?

나는 7개의 열이 있는 매우 간단한 테이블( tabular/x/*, 무엇이든)을 원합니다. 각 열은 의 14% \linewidth, 총 98%입니다.

그러나 어떤 이유로 가장 오른쪽 열은 a) 여백에 있고 b) 테이블 규칙 외부에 있습니다. 여기에 이미지 설명을 입력하세요

어떻게 해결하나요?

\documentclass[version=last,12pt]{scrreport}
\usepackage{tabularx,booktabs}

\begin{document}
\begin{table}[t]
\tiny
\begin{tabularx}{\linewidth}{@{}
p{0.14\linewidth}
p{0.14\linewidth}
p{0.14\linewidth}
p{0.14\linewidth}
p{0.14\linewidth}
p{0.14\linewidth}
p{0.14\linewidth}
@{}
}
\toprule
Excavator
& Alphanumeric data 
& Location 
& Warranty details 
& Expiry date of the support period 
& Required business properties
& Maximum needed diesel
\\
\bottomrule
\end{tabularx}
\end{table}

\end{document}     

답변1

첫 번째 버전: tabularxX유형 열을 사용하면 텍스트 너비와 정확히 같고 너비가 동일한 7개의 열로 구성된 테이블이 생성됩니다. 열을 왼쪽 정렬하기 위해 >{\raggedright\arraybackslash}새로운 사용자 정의 열 유형을 사용하고 정의했습니다 L.

\tabcolsep두 번째 버전: 여기에서는 각 열 내용의 왼쪽과 오른쪽에 추가되는 값을 고려하여 열 너비를 수동으로 계산했습니다 . 보시다시피 결과 테이블은 예상대로 텍스트 너비보다 약간 좁습니다.

세 번째 버전: 이 버전에서는 표가 텍스트 너비만큼 넓은지 확인하기 위해 tabular*와 함께 사용했습니다 .\extracolsep{\fill}}

다음 스크린샷의 수직선은 패키지로 인해 발생하며 showframe여백의 텍스트 너비/시작을 보여줍니다.

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

\tiny참고 사항: 이 예에서는 글꼴 크기가 사용되었으면 좋겠습니다 . 이 글꼴 크기는 너무 작아서 읽기가 매우 어려우므로 사용하지 않는 것이 좋습니다. 일반 글꼴 크기를 사용하더라도 표를 텍스트 너비에 쉽게 맞출 수 있으므로 다음과 유사한 출력이 생성됩니다.

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

테이블 내용에 따라 다양한 열 너비를 허용하는 것이 도움이 될 수도 있습니다.

\documentclass[version=last,12pt]{scrreport}
\usepackage{tabularx,booktabs}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}

\newcolumntype{Z}[2]{>{\raggedright\arraybackslash}p{\dimexpr #1\textwidth- #2\tabcolsep} }

\newcolumntype{Y}[1]{>{\raggedright\arraybackslash}p{\dimexpr #1\textwidth} }

\usepackage{showframe}
\begin{document}
\begin{table}[t]
\tiny
\begin{tabularx}{\linewidth}{@{}*{7}{L}@{}}
\toprule
Excavator
& Alphanumeric data 
& Location 
& Warranty details 
& Expiry date of the support period 
& Required business properties
& Maximum needed diesel
\\
\bottomrule
\end{tabularx}
\end{table}


\begin{table}[t]
\tiny
\begin{tabular}{@{}Z{0.14}{1} 
                   *{5}{Z{0.14}{2}}
                   Z{0.14}{1} @{}}
\toprule
Excavator
& Alphanumeric data 
& Location 
& Warranty details 
& Expiry date of the support period 
& Required business properties
& Maximum needed diesel
\\
\bottomrule
\end{tabular}
\end{table}


\begin{table}[t]
\tiny \setlength{\tabcolsep}{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{7}{Y{0.14}}}
\toprule
Excavator
& Alphanumeric data 
& Location 
& Warranty details 
& Expiry date of the support period 
& Required business properties
& Maximum needed diesel
\\
\bottomrule
\end{tabular*}
\end{table}

\end{document}

 

관련 정보