这是一个明确的问题 此版本,我希望表格中的红色区域能够顺利移动到下一页。
\documentclass[12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage[top=2cm, bottom=2cm]{geometry}
\usepackage{tabularx}
\usepackage{blindtext}
\newcolumntype{f}{>{\hsize=.2\hsize}X}
\newcolumntype{s}{>{\hsize=.3\hsize}X}
\newcolumntype{t}{>{\hsize=.5\hsize}X}
\newcommand{\heading}[1]{\multicolumn{1}{|c|}{#1}}
\fancyheadoffset{0pt}
\rhead{}%
\lhead{}%
\chead{}
\cfoot{}
\lfoot{}
\rfoot{\textit{Page \thepage\ / \pageref{LastPage}} }%\thepage
\renewcommand{\footrulewidth}{2pt}
\renewcommand{\headrulewidth}{2pt}
\pagestyle{fancy}
\begin{document}
\begin{table}
\caption{Sample table}
\centering
\begin{tabularx}{\textwidth}{|f|s|t|}
\hline
\heading{\textbf{\makecell{Short\\Column}}} & \heading{\textbf{Medium Column}} & \heading{\textbf{Long Column}} \\ \hline
ot yet found the solution. The problem is the following: For a business report, the requirement is to report the data in two different tables as follows: - The tables will be put side by side. - The tables will span multiple pages. - On each table,& \blindtext[1] & ot yet found the solution. The problem is the following: For a business report, the requirement is to report the data in two different tables as follows: - The tables will be put side by side. - The tables will span multiple pages. - On each table, one of the columns will have a wrapping content (e.g. defined as p{4cm}). As a consequence the lines of the two tables will not be aligned, so I cannot use a single table with the column doubled.I have looked in all previously related questions but I have not yet found the solution. The problem is the following: For a business report, the requirement is to \\ \hline
Value & Text & This text is too long to fit in one line and is automatically I have looked in all previously related questions but I have not yet found the solution. The problem is the following: For a business report, the requirement is to report the data in he lines of the two tables will not be aligned, so I cannot use a single table with the column doubled.I have looked in all previously related questions but I have not yet found the solution. The problem is the following: For a business report, the requirement is to report the data in two different tables as follows: - The tables will be put side by side. - The tables will span multiple pages. - On each table, one of the columns will have a wrapping content (e.g. defined as p{4cm}). As a consequence the lines of the two tables will not be aligned, so I cannot use a single table with the column doubled.I have looked in all a split into three \\ \hline
Value & Text & have not yet found the solution. The problem is the following: For a business report, the requirement is to report the data in two different tables as follows: - The tables will be put side by side. - The tables will span multiple pages. - On each table, one of the columns will have a wrapping content (e.g. defined as p{4cm}). As a consequence the lines of the two tables will not be aligned, so I cannot use a single table with the column doubled.I have looked in all previously related questions but I have not yet \newline
have n\newline
- 7: items \\ \hline
\end{tabularx}
\end{table}
\end{document}
答案1
正如@user202729 在其评论中提到的,您的表格太长,无法放在一页中,因此您需要使用某种长表格,例如由包定义的表格xltabular
。
警告:任何长表格都只能在页面之间拆分,而不能在行之间拆分!
为了更好地在单元格中留出文本间距,建议使用较小的字体,例如,\footnotesize
但这取决于您:
\documentclass[12pt]{book}
\usepackage[margin=2cm]{geometry}
\usepackage{ragged2e}
\usepackage{makecell, xltabular}
\renewcommand\theadfont{\footnotesize\bfseries}
\newcolumntype{R}{>{\RaggedRight}X}
\usepackage{enumitem}
\newlist{tabitemize}{itemize}{1}
\setlist[tabitemize]{nosep,
leftmargin = *,
label = $\bullet$ ,
before = \begin{minipage}[t]{\linewidth},
after = \end{minipage}
}
\usepackage{blindtext}
\begin{document}
\begingroup
\footnotesize
\setlength\tabcolsep{4pt}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{xltabular}{\textwidth}{|>{\hsize=0.6\hsize\linewidth=\hsize}R
|>{\hsize=0.9\hsize\linewidth=\hsize}R
|>{\hsize=1.5\hsize\linewidth=\hsize}R|}
\caption{Sample table}
\label{tab:longtable} \\
\hline
\thead{Short\\Column} & \thead{Medium\\ Column} & \thead{Long\\ Column} \\
\hline
\endfirsthead
\caption[]{Sample table (cont.)}\\
\hline
\thead{Short\\Column} & \thead{Medium\\ Column} & \thead{Long\\ Column} \\
\hline
\endhead
\multicolumn{3}{r}{\footnotesize\itshape{Continued on the next page}} \\
\endfoot
\endlastfoot
% table body
Not yet found the solution. The problem is the following: For a business report, the requirement is to report the data in two different tables as follows:
\begin{tabitemize}
\item The tables will be put side by side.
\item The tables will span multiple pages.
\item On each table,
\end{tabitemize}
& \blindtext[1]
& \begin{tabitemize}
\item Not yet found the solution. The problem is the following: For a business report, the requirement is to report the data in two different tables as follows:
\item The tables will be put side by side.
\item The tables will span multiple pages.
\item On each table, one of the columns will have a wrapping content (e.g. defined as p{4cm}).
\end{tabitemize}
As a consequence the lines of the two tables will not be aligned, so I cannot use a single table with the column doubled.I have looked in all previously related questions but I have not yet found the solution. The problem is the following: For a business report, the requirement is to \\
\hline
Value
& Text
& This text is too long to fit in one line and is automatically I have looked in all previously related questions but I have not yet found the solution. The problem is the following: For a business report, the requirement is to report the data in he lines of the two tables will not be aligned, so I cannot use a single table with the column doubled.I have looked in all previously related questions but I have not yet found the solution. The problem is the following: For a business report, the requirement is to report the data in two different tables as follows:
\begin{tabitemize}
\item The tables will be put side by side.
\item The tables will span multiple pages.
\item On each table, one of the columns will have a wrapping content (e.g. defined as p{4cm}).
\end{tabitemize}
As a consequence the lines of the two tables will not be aligned, so I cannot use a single table with the column doubled.I have looked in all a split into three \\
\hline
Value
& Text
& have not yet found the solution. The problem is the following: For a business report, the requirement is to report the data in two different tables as follows: - The tables will be put side by side. - The tables will span multiple pages. - On each table, one of the columns will have a wrapping content (e.g. defined as p{4cm}). As a consequence the lines of the two tables will not be aligned, so I cannot use a single table with the column doubled.I have looked in all previously related questions but I have not yet \\
\hline
\end{xltabular}
\end{document}
附录:
您可以考虑使用tabularray
包及其longtblr
表。代码更短更简单,但结果(在我看来)更好:
\documentclass[12pt]{book}
\usepackage[margin=2cm]{geometry}
\usepackage{tabularray}
\UseTblrLibrary{varwidth}
\usepackage{enumitem}
\newlist{tabitemize}{itemize}{1}
\setlist[tabitemize]{nosep,
leftmargin = *,
label = $\bullet$ ,
before = \begin{minipage}[t]{\linewidth},
after = \end{minipage}
}
\usepackage{blindtext}
\begin{document}
\begin{longtblr}[
caption = {Sample table},
label = {longtable},
]{rowhead=1,
hlines, vlines,
colspec = {X[0.2,j] X[0.3,j] X[0.53,j]},
rows = {font=\footnotesize},
row{1} = {font=\footnotesize\bfseries},
measure = vbox
}
% column headers
{Short Column} & {Medium Column} & {Long Column} \\
% table body
Not yet found the solution. The problem is the following: For a business report, the requirement is to report the data in two different tables as follows:
\begin{tabitemize}
\item The tables will be put side by side.
\item The tables will span multiple pages.
\item On each table,
\end{tabitemize}
& \blindtext[1]
& \begin{tabitemize}
\item Not yet found the solution. The problem is the following: For a business report, the requirement is to report the data in two different tables as follows:
\item The tables will be put side by side.
\item The tables will span multiple pages.
\item On each table, one of the columns will have a wrapping content (e.g. defined as p{4cm}).
\end{tabitemize}
As a consequence the lines of the two tables will not be aligned, so I cannot use a single table with the column doubled.I have looked in all previously related questions but I have not yet found the solution. The problem is the following: For a business report, the requirement is to \\
Value
& Text
& This text is too long to fit in one line and is automatically I have looked in all previously related questions but I have not yet found the solution. The problem is the following: For a business report, the requirement is to report the data in he lines of the two tables will not be aligned, so I cannot use a single table with the column doubled.I have looked in all previously related questions but I have not yet found the solution. The problem is the following: For a business report, the requirement is to report the data in two different tables as follows:
\begin{tabitemize}
\item The tables will be put side by side.
\item The tables will span multiple pages.
\item On each table, one of the columns will have a wrapping content (e.g. defined as p{4cm}).
\end{tabitemize}
As a consequence the lines of the two tables will not be aligned, so I cannot use a single table with the column doubled.I have looked in all a split into three \\
Value
& Text
& have not yet found the solution. The problem is the following: For a business report, the requirement is to report the data in two different tables as follows: - The tables will be put side by side. - The tables will span multiple pages. - On each table, one of the columns will have a wrapping content (e.g. defined as p{4cm}). As a consequence the lines of the two tables will not be aligned, so I cannot use a single table with the column doubled.I have looked in all previously related questions but I have not yet \\
\end{longtblr}
\end{document}