Latexで長い表をフォーマットするのに助けが必要です

Latexで長い表をフォーマットするのに助けが必要です

2 ページにわたる長い表の書式設定に問題があります。現在のコードは次のとおりです。

ここに画像の説明を入力してください

\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 の後に \ を挿入しましたが、これは機能しますが、各段落の上と下の間隔が同じサイズにならず、表の 2 ページ目の 3. Verbal の上に空の行が追加されます。間隔が同じサイズになるように、\ の代わりに各 \hline の後ろに \vspace{1mm} を追加しようとしましたが、プログラムがクラッシュします。

見た目を良くするために他に何かできることはありますか?

答え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}

ここに画像の説明を入力してください

編集

一般的には、私は Mico の提案に同意しますが、提供されたテーブル スタイル (私が複製したもの) を好む場合は、最も長いエントリを使用して Mico が提案したように列幅を計算することをお勧めします。

\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

Mico がコメントで示唆しているように、太字フォント バージョンのテキストの幅は、通常のフォントの太さの幅と異なるため、計算する必要があります。さらに、\tabcolsepこの例では、Mico の例と比べて 2 つ多くあります。1 つは表の一番左にあり、もう 1 つは一番右にあります。Mico は@{}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}

関連情報