
만들 때 tabularx
테이블 너비를 제공해야 합니다. 가장 바깥쪽 테이블의 경우 \textwidth
.
외부 테이블 내부에 하나 이상의 내부 테이블을 만들 때 내부 테이블에도 너비가 필요합니다. 이 경우 이 내부 테이블이 발생한 외부 테이블의 열 너비가 됩니다. in. 컨텍스트를 추적하고 하드코딩된 값을 수동으로 제공하는 것은 어렵습니다.
LaTeX에게 외부 테이블에서 사용 가능한 모든 열 너비를 사용하고 LaTeX에서 계산을 수행하도록 지시하는 방법을 알 수 없습니다. X
테이블 너비 자체 와 비슷하지만 필요한 것이 필요합니다 .
다음은 MWE 테이블 하나와 다른 테이블 하나입니다.
\documentclass[10pt,notitlepage]{article}%
\usepackage{tabularx}
\usepackage{hyperref}
\usepackage{array}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
%have to use tabular* for outer table since I can't figure how to use tabularx
\begin{tabular*}{\textwidth}{|p{0.5\textwidth}|p{0.5\textwidth}|}\hline
\begin{tabularx}{0.5\textwidth}{@{}|Y|Y|Y|@{}}\hline % how to automate this?
% instead of 0.5\textwidth
% use full column width
\href{foo/index.htm}{A}
\begin{enumerate}
\item item 1
\item item 2
\end{enumerate}&
\href{foo/index.htm}{B}&
\href{foo/index.htm}{C}\\\hline
\end{tabularx}
&
second column
\end{tabular*}
\end{document}
답변1
당신이 사용할 수있는 \linewidth
. 유용한 참고자료는 다음과 같습니다:이 Q와 그 A. p{\dimexpr0.5\textwidth-2\tabcolsep\relax}
외부 테이블에 사용하고 왼쪽 정렬 셀 구조를 사용하는 것이 더 좋습니다 enumerate
.
\documentclass[10pt,notitlepage]{article}%
\usepackage{tabularx}
\usepackage{hyperref}
\usepackage{array}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
%have to use tabular* for outer table since I can't figure how to use tabularx
\noindent\begin{tabular*}{\textwidth}{|p{\dimexpr0.5\textwidth-2\tabcolsep\relax}|
@{\extracolsep{\fill}}p{\dimexpr0.5\textwidth-2\tabcolsep\relax}|}\hline
\begin{tabularx}{\linewidth}{@{}|p{0.35\hsize}|Y|Y|@{}}\hline % how to automate this?
% instead of 0.5\textwidth
% use full column width
{\centering \href{foo/index.htm}{A}\par}
\begin{enumerate}
\item item 1
\item item 2
\end{enumerate}
&
\href{foo/index.htm}{B}&
\href{foo/index.htm}{C}\\\hline
\end{tabularx}
&
second column
\end{tabular*}
\end{document}
답변2
이것이 당신이 달성하고 싶은 것인지 확인하십시오:
\documentclass[10pt,notitlepage]{article}%
\usepackage{array,tabularx,hyperref}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
\begin{tabularx}{\textwidth}{|@{}X@{}|X|}%outer table, @{} omit column separation
\hline
{\begin{tabularx}{\hsize}{|Y|Y|Y|}
\hline
\href{foo/index.htm}{A}
\begin{enumerate}
\item item 1
\item item 2
\end{enumerate} &
\href{foo/index.htm}{B} &
\href{foo/index.htm}{C} \\
\hline
\end{tabularx}}
& second column \\
\end{tabularx}
\end{document}