
У меня возникли проблемы с форматированием длинной таблицы на двух страницах. Вот мой текущий код:
\begin{longtable}{p{5cm}p{9cm}}
\caption{Descriptions of learning styles \citep{Hoerner2013}}\\
\hline
\multicolumn{1}{c}{\textbf{Learning Style}} & \multicolumn{1}{c}{\textbf{Description}} \\\hline
\endhead
\multicolumn{1}{c}{1. Visual} & \parbox[c]{\hsize}{People who understand work better when it is in the form of a diagram. Knowledge and concept maps are good tools for such learners.} \vspace{1mm} \\\hline
\multicolumn{1}{c}{2. Aural} & \parbox[c]{\hsize}{\vspace{1mm} People who dislike reading, but enjoys hearing someone else say something aloud. Hearing the information is key for such students and group discussions can be of great aid.} \vspace{1mm} \\\hline
\multicolumn{1}{c}{3. Verbal} & \parbox[c]{\hsize}{Verbal learners are people who express themselves easier through writing and speaking. Mnemonics, scripting and role playing are some great techniques to helps those learners.} \vspace{1mm} \\\hline
\multicolumn{1}{c}{4. Physical} & \parbox[c]{\hsize}{Hands-on activities rather than lectures or demonstrations appeal to these learners. They are a small percentage of the population, but they learn better through practical experience.} \vspace{1mm} \\\hline
\multicolumn{1}{c}{5. Logical} & \parbox[c]{\hsize}{People who are good with numbers and using logic to understand. They easily recognize patterns and often tend to group information to further their understanding.} \vspace{1mm} \\\hline
\multicolumn{1}{c}{6. Social} & \parbox[c]{\hsize}{When communicating and socialising with others come easy, someone is a social learner. Studying in group formats and learning from others are their speciality and is how they excel.} \vspace{1mm} \\\hline
\multicolumn{1}{c}{7. Solitary} & \parbox[c]{\hsize}{People who are more comfortable studying in private and introspective. The concentration of these students are at their peak when they can focus on their own thoughts without the distractions of others around them.} \vspace{1mm} \\\hline
\label{learningstyles}
\end{longtable}
и отображается как на прикрепленном рисунке. Как можно увидеть, в каждой строке таблицы hline находится очень близко к верху каждого абзаца. Я вставил \ после каждой \hline, что работает, но тогда интервал над каждым абзацем и под ним не одинакового размера, и пустая строка добавляется над 3. Verbal на второй странице таблицы. Я попробовал добавить \vspace{1mm} после каждой \hline вместо \, чтобы интервал был одинакового размера, но тогда программа вылетает.
Могу ли я что-то еще сделать, чтобы он выглядел лучше?
решение1
Не используйте \hline
и \cline
; вместо этого загрузите booktabs
пакет и используйте его команды рисования линий \toprule
, \midrule
, \bottomrule
, и .\addlinespaces
Я бы также заменил внутренние горизонтальные линии пробелами, не центрировал бы содержимое столбцов и не злоупотреблял бы выделением жирным шрифтом.
\documentclass{article} % select a suitable document class
\usepackage{natbib, longtable, booktabs}
\newlength\mylen
\settowidth\mylen{Learning Style}
% Calculate maximal permissible width of second column:
\setlength\mylen{\dimexpr\textwidth-\mylen-2\tabcolsep\relax}
\begin{document}
\frenchspacing
\begin{longtable}{@{}lp{\mylen}@{}}
\caption{Descriptions of learning styles \citep{Hoerner2013}}
\label{learningstyles} \\
\toprule
Learning Style & Description \\
\midrule
\endhead
\bottomrule
\endfoot
1. Visual & People who understand work better when it is in the form of a diagram. Knowledge and concept maps are good tools for such learners. \\
\addlinespace
2. Aural & People who dislike reading, but enjoys hearing someone else say something aloud. Hearing the information is key for such students and group discussions can be of great aid. \\
\addlinespace
3. Verbal & Verbal learners are people who express themselves easier through writing and speaking. Mnemonics, scripting and role playing are some great techniques to helps those learners. \\
\addlinespace
4. Physical & Hands-on activities rather than lectures or demonstrations appeal to these learners. They are a small percentage of the population, but they learn better through practical experience. \\
\addlinespace
5. Logical & People who are good with numbers and using logic to understand. They easily recognize patterns and often tend to group information to further their understanding. \\
\addlinespace
6. Social & When communicating and socialising with others come easy, someone is a social learner. Studying in group formats and learning from others are their speciality and is how they excel. \\
\addlinespace
7. Solitary & People who are more comfortable studying in private and introspective. The concentration of these students are at their peak when they can focus on their own thoughts without the distractions of others around them. \\
\end{longtable}
\end{document}
решение2
С помощью xltabular
ширины столбцов можно автоматически определить:
\documentclass{article}
\usepackage{booktabs, makecell, xltabular}
\renewcommand\theadfont{\normalsize\bfseries}
\usepackage{lipsum}
\begin{document}
\lipsum[1-3]
\begin{xltabular}{\linewidth}{@{} lX @{}}
\caption{Descriptions of learning styles}
\label{learningstyles} \\
\toprule
\thead{Learning\\ Style} & \thead{Description} \\
\midrule
\endfirsthead
\caption[]{Descriptions of learning styles (cont.)} \\
\toprule
\thead{Learning\\ Style} & \thead{Description} \\
\midrule
\endhead
\midrule
\multicolumn{2}{r}{%
\footnotesize\textit{Continue on the next page}}\\
\endfoot
\bottomrule
\endlastfoot
1. Visual
& People who understand work better when it is in the form of a diagram. Knowledge and concept maps are good tools for such learners.\\
\addlinespace
2. Aural
& People who dislike reading, but enjoys hearing someone else say something aloud. Hearing the information is key for such students and group discussions can be of great aid.\\
\addlinespace
3. Verbal
& Verbal learners are people who express themselves easier through writing and speaking. Mnemonics, scripting and role playing are some great techniques to helps those learners.\\
\addlinespace
4. Physical
& Hands-on activities rather than lectures or demonstrations appeal to these learners. They are a small percentage of the population, but they learn better through practical experience.\\
\addlinespace
5. Logical
& People who are good with numbers and using logic to understand. They easily recognize patterns and often tend to group information to further their understanding.\\
\addlinespace
6. Social
& When communicating and socialising with others come easy, someone is a social learner. Studying in group formats and learning from others are their speciality and is how they excel.\\
\addlinespace
7. Solitary
& People who are more comfortable studying in private and introspective. The concentration of these students are at their peak when they can focus on their own thoughts without the distractions of others around them.\\
\end{xltabular}
\end{document}
решение3
Подумайте о том, чтобы удалить , \parbox
который является причиной странных интервалов, и заменить его столбцами m
пакета array
.
Я также использовала этот booktabs
пакет для создания более красивых горизонтальных линий.
\documentclass{article}
\usepackage{longtable}
\usepackage{array}
\usepackage{booktabs}
\begin{document}
\begin{longtable}{m{5cm}m{9cm}}
\caption{Descriptions of learning styles}\\
\toprule
\multicolumn{1}{c}{\textbf{Learning Style}} & \multicolumn{1}{c}{\textbf{Description}} \\
\midrule
\endhead
\multicolumn{1}{c}{1. Visual}
& People who understand work better when it is in the form of a diagram. Knowledge and concept maps are good tools for such learners.\\
\midrule
\multicolumn{1}{c}{2. Aural}
& People who dislike reading, but enjoys hearing someone else say something aloud. Hearing the information is key for such students and group discussions can be of great aid.\\
\midrule
\multicolumn{1}{c}{3. Verbal}
& Verbal learners are people who express themselves easier through writing and speaking. Mnemonics, scripting and role playing are some great techniques to helps those learners.\\
\midrule
\multicolumn{1}{c}{4. Physical}
& Hands-on activities rather than lectures or demonstrations appeal to these learners. They are a small percentage of the population, but they learn better through practical experience.\\
\midrule
\multicolumn{1}{c}{5. Logical}
& People who are good with numbers and using logic to understand. They easily recognize patterns and often tend to group information to further their understanding.\\
\midrule
\multicolumn{1}{c}{6. Social}
& When communicating and socialising with others come easy, someone is a social learner. Studying in group formats and learning from others are their speciality and is how they excel.\\
\midrule
\multicolumn{1}{c}{7. Solitary}
& People who are more comfortable studying in private and introspective. The concentration of these students are at their peak when they can focus on their own thoughts without the distractions of others around them.\\
\bottomrule
\label{learningstyles}
\end{longtable}
\end{document}
Редактировать
В целом я согласен с предложениями Мико, но если вы предпочитаете предоставленный вами стиль таблицы (который я скопировал), я бы все равно рекомендовал рассчитать ширину столбца, как предлагает Мико, используя самую длинную запись.
\documentclass{article}
\usepackage{longtable}
\usepackage{array}
\usepackage{booktabs}
\newlength\colOne
\newlength\colTwo
\settowidth\colOne{Learning Style}
% Calculate maximal permissible width of second column:
\setlength\colTwo{\dimexpr\textwidth-\colOne-2\tabcolsep\relax}
\begin{document}
\begin{longtable}{m{\colOne}m{\colTwo}}
\caption{Descriptions of learning styles}\\
\toprule
\multicolumn{1}{c}{\textbf{Learning Style}} & \multicolumn{1}{c}{\textbf{Description}} \\
\midrule
\endhead
\multicolumn{1}{c}{1. Visual}
& People who understand work better when it is in the form of a diagram. Knowledge and concept maps are good tools for such learners.\\
\midrule
\multicolumn{1}{c}{2. Aural}
& People who dislike reading, but enjoys hearing someone else say something aloud. Hearing the information is key for such students and group discussions can be of great aid.\\
\midrule
\multicolumn{1}{c}{3. Verbal}
& Verbal learners are people who express themselves easier through writing and speaking. Mnemonics, scripting and role playing are some great techniques to helps those learners.\\
\midrule
\multicolumn{1}{c}{4. Physical}
& Hands-on activities rather than lectures or demonstrations appeal to these learners. They are a small percentage of the population, but they learn better through practical experience.\\
\midrule
\multicolumn{1}{c}{5. Logical}
& People who are good with numbers and using logic to understand. They easily recognize patterns and often tend to group information to further their understanding.\\
\midrule
\multicolumn{1}{c}{6. Social}
& When communicating and socialising with others come easy, someone is a social learner. Studying in group formats and learning from others are their speciality and is how they excel.\\
\midrule
\multicolumn{1}{c}{7. Solitary}
& People who are more comfortable studying in private and introspective. The concentration of these students are at their peak when they can focus on their own thoughts without the distractions of others around them.\\
\bottomrule
\label{learningstyles}
\end{longtable}
\end{document}
Редактировать 2
Как предложил Мико в своем комментарии, мы должны вычислить ширину жирного шрифта-версии текста, поскольку она отличается от обычной ширины шрифта. Более того, \tabcolsep
в этом примере их два больше по сравнению с примером Мико. Один в самом левом углу таблицы, а другой в самом правом. Мико подавил их, написав @{}lp{\mylen}@{}
, где @{}
используется для \tabcolsep
локального сброса к любому размеру между фигурными скобками, так что в этом случае ничего.
Таким образом, код для расчета ширины столбцов следует заменить на следующий:
\newlength\colOne
\newlength\colTwo
\settowidth\colOne{\textbf{Learning Style}}
% Calculate maximal permissible width of second column:
\setlength\colTwo{\dimexpr\textwidth-\colOne-4\tabcolsep\relax}