
Я создаю таблицы для приложения к своей диссертации, и у меня возникли следующие проблемы с одной из таблиц:
- Моя таблица начинается на следующей странице. Что мне следует изменить, если я хочу, чтобы моя таблица была разделена на несколько страниц?
- Я хотел бы добавить вертикальную линию между вторым и третьим столбцом (поскольку информация, представленная в столбцах 1 и 2, такая же, как информация, представленная в столбцах 3 и 4).
Я покажу вам код, который я использовал, и его результат (обратите внимание, что я уже использовал newcolumntypes для других таблиц в документе). Таблица должна начинаться после приложения B.
\usepackage{array,ragged2e}
\newcolumntype{C}{>{\Centering\hspace{0pt}}p{0.1\textwidth}}
\usepackage[output-decimal-marker={,}]{siunitx}
\usepackage{booktabs, makecell, tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\section{Suppliers´ production capabilities}
\begin{table}[ht]
\resizebox{\textwidth}{!}{%
\begin{tabular}{lllll}
\toprule
\multicolumn{1}{c}{\textbf{Facility Name}} & \multicolumn{1}{c}{\textbf{Product}} & \multicolumn{1}{c}{\textbf{Facility Name}} & \multicolumn{1}{c}{\textbf{Product}} \\
\midrule
Texttexttexttexttexttextt & Wordswordswordswordswordswords & Texttexttexttexttexttexttex & Wordswordswordswordswordswords \\
Texttexttexttexttexttextt & Wordswordswordswordswordswords & Texttexttexttexttexttexttex & Wordswordswordswordswordswords \\
Texttexttexttexttexttextt & Wordswordswordswordswordswords & Texttexttexttexttexttexttex & Wordswordswordswordswordswords \\
Texttexttexttexttexttextt & Wordswordswordswordswordswords & Texttexttexttexttexttexttex & Wordswordswordswordswordswords \\
Texttexttexttexttexttextt & Wordswordswordswordswordswords & Texttexttexttexttexttexttex & Wordswordswordswordswordswords \\
Texttexttexttexttexttextt & Wordswordswordswordswordswords & Texttexttexttexttexttexttex & Wordswordswordswordswordswords \\
Texttexttexttexttexttextt & Wordswordswordswordswordswords & Texttexttexttexttexttexttex & Wordswordswordswordswordswords \\
Texttexttexttexttexttextt & Wordswordswordswordswordswords & Texttexttexttexttexttexttex & Wordswordswordswordswordswords \\
Texttexttexttexttexttextt & Wordswordswordswordswordswords & Texttexttexttexttexttexttex & Wordswordswordswordswordswords \\
Texttexttexttexttexttextt & Wordswordswordswordswordswords & Texttexttexttexttexttexttex & Wordswordswordswordswordswords \\
Texttexttexttexttexttextt & Wordswordswordswordswordswords & Texttexttexttexttexttexttex & Wordswordswordswordswordswords \\
Texttexttexttexttexttextt & Wordswordswordswordswordswords & Texttexttexttexttexttexttex & Wordswordswordswordswordswords \\
Texttexttexttexttexttextt & Wordswordswordswordswordswords \\
\bottomrule
\end{tabular}%
}
\caption{Supplier facilities´ production capabilities }
\label{tab:my-table}
\end{table}
Я был бы очень признателен, если бы вы помогли мне с этой проблемой!
решение1
Вот longtable
решение на основе -. Все четыре столбца допускают автоматический перенос строк. Ширина столбцов одинакова и рассчитывается таким образом, чтобы занять максимально доступную ширину.
\documentclass{article}
\usepackage[hmargin=1in]{geometry} % set page parameters suitably
\usepackage{longtable,array,ragged2e}
\newlength\mylen
\setlength\mylen{\dimexpr0.25\textwidth-1.5\tabcolsep-0.25\arrayrulewidth\relax}
\newcolumntype{Z}{>{\RaggedRight}p{\mylen}}
\begin{document}
\section{Suppliers' production capabilities}
\setlength{\extrarowheight}{2pt}
\begin{longtable}{@{} ZZ | ZZ @{}}
%%% headers and footers:
\caption{Supplier facilities' production capabilities }
\label{tab:my-table}\\
\hline
\textbf{Facility Name} & \textbf{Product} &
\textbf{Facility Name} & \textbf{Product} \\
\hline
\endfirsthead
\multicolumn{4}{@{}l}{Table \thetable, cont'd}\\[1ex]
\hline
\textbf{Facility Name} & \textbf{Product} &
\textbf{Facility Name} & \textbf{Product} \\
\hline
\endhead
\hline
\multicolumn{4}{r@{}}{\footnotesize cont'd on following page}\\
\endfoot
\hline
\endlastfoot
%%% Body of table
Texttext texttextt exttexttex exttexttex & Wordswordswords wordswordswords & Texttext texttextt exttexttex exttexttex & Wordswordswords wordswordswords \\
Texttext texttextt exttextt & Wordswordswords wordswordswords & Texttext texttextt exttexttex exttexttex & Wordswordswords wordswordswords \\
Texttext texttextt exttextt & Wordswordswords wordswordswords & Texttext texttextt exttexttex exttexttex & Wordswordswords wordswordswords \\
Texttext texttextt exttextt & Wordswordswords wordswordswords & Texttext texttextt exttexttex exttexttex & Wordswordswords wordswordswords \\
Texttext texttextt exttextt & Wordswordswords wordswordswords & Texttext texttextt exttexttex exttexttex & Wordswordswords wordswordswords \\
Texttext texttextt exttextt & Wordswordswords wordswordswords & Texttext texttextt exttexttex exttexttex & Wordswordswords wordswordswords \\
Texttext texttextt exttextt & Wordswordswords wordswordswords & Texttext texttextt exttexttex exttexttex & Wordswordswords wordswordswords \\
Texttext texttextt exttextt & Wordswordswords wordswordswords & Texttext texttextt exttexttex exttexttex & Wordswordswords wordswordswords \\
Texttext texttextt exttextt & Wordswordswords wordswordswords & Texttext texttextt exttexttex exttexttex & Wordswordswords wordswordswords \\
\end{longtable}
\end{document}
решение2
Вот как использовать xltabular
– это тот же синтаксис, что и для longtable, за исключением того, что вы объявляете общую ширину. В частности, в longtable вы не используете окружение table
(это не float), заголовок включен в таблицу, впервый головараздел.
\documentclass{article}
\usepackage{array,ragged2e}
\newcolumntype{C}{>{\Centering\hspace{0pt}}p{0.1\textwidth}}
\usepackage[output-decimal-marker={,}]{siunitx}
\usepackage{lipsum}
\usepackage{booktabs, makecell, xltabular}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}
\section{Suppliers´ production capabilities}
\lipsum[1-3]
\begin{xltabular}{\textwidth}{*{4}{L}}
\caption{Supplier facilities´ production capabilities }
\label{tab:my-table} \\
\toprule
\multicolumn{1}{c}{\textbf{Facility Name}} & \multicolumn{1}{c}{\textbf{Product}} & \multicolumn{1}{c}{\textbf{Facility Name}} & \multicolumn{1}{c}{\textbf{Product}} \\
\midrule
\endfirsthead
{\footnotesize (Continued)}\\
\toprule
\multicolumn{1}{c}{\textbf{Facility Name}} & \multicolumn{1}{c}{\textbf{Product}} & \multicolumn{1}{c}{\textbf{Facility Name}} & \multicolumn{1}{c}{\textbf{Product}} \\
\midrule
\endhead
\midrule
\multicolumn{4}{r}{\footnotesize (to be continued)}
\endfoot
\bottomrule
\endlastfoot
Text text text text text textt & Words words words words words words & Text text text text text text tex & Words words words words words words \\ \addlinespace
Text text text text text textt & Words words words words words words & Text text text text text text tex & Words words words words words words \\ \addlinespace
Text text text text text textt & Words words words words words words & Text text text text text text tex & Words words words words words words \\ \addlinespace
Text text text text text textt & Words words words words words words & Text text text text text text tex & Words words words words words words \\ \addlinespace
Text text text text text textt & Words words words words words words & Text text text text text text tex & Words words words words words words \\ \addlinespace
Text text text text text textt & Words words words words words words & Text text text text text text tex & Words words words words words words \\ \addlinespace
Text text text text text textt & Words words words words words words & Text text text text text text tex & Words words words words words words \\ \addlinespace
Text text text text text textt & Words words words words words words & Text text text text text text tex & Words words words words words words \\ \addlinespace
Text text text text text textt & Words words words words words words & Text text text text text text tex & Words words words words words words \\ \addlinespace
Text text text text text textt & Words words words words words words & Text text text text text text tex & Words words words words words words \\ \addlinespace
Text text text text text textt & Words words words words words words & Text text text text text text tex & Words words words words words words \\ \addlinespace
Text text text text text textt & Words words words words words words & Text text text text text text tex & Words words words words words words \\ \addlinespace
Text text text text text textt & Words words words words words words \
\end{xltabular}%
\end{document}