コース一覧の表に奇妙な配置の問題がある

コース一覧の表に奇妙な配置の問題がある

私はすべてのコースワークの詳細を含むテーブルを作成しようとしています。次のコードを書きました。これにはいくつか問題があります。

  1. コンパイルすると 1 ページ目が空白になるのはなぜですか (2 ページ目に表がある)?
  2. 表のページの左余白に多くのスペースが残っているようで、これを使用して 4 番目の列を広くすることができますが、そのスペースを使用できないようです。
  3. 表は 2 ページ目の下部にあるページ番号を超えており、2 ページ目に表示されている内容の後に何も表示されません。他にもいくつかのコースがあり、この表を約 3 ページにまたがるようにしたいと考えています。どうすればよいですか?

注: 一部のインストラクターの本名は 2 行必要なので、2 番目の列を p 列にしました。

コードは次のとおりです:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{booktabs}

\begin{document}
\begin{tabular}{p{2.5cm}p{2cm}lp{6cm}} 
\toprule[2pt] 
Name of Course & Instructor & Book(s) Referred & Brief List of Topics Covered \\ 
\hline
\\[\defaultaddspace]

Algebra I & ABC & Herstein; M. Artin & 
\parbox{6cm}{Basic Set Theory; Group Theory\\(upto Sylow theorems);\\ Introduction to Ring Theory} \\ 
\\[\defaultaddspace]

Algebra II & DEF & Hoffman and Kunze & 
\parbox{6cm}{Linear Algebra \\(upto Spectral theorems)} \\ 
\\[\defaultaddspace]

Algebra III & GHI & S. Lang & 
\parbox{6cm}{Ring and Module Theory\\(covering Hilbert basis theorem and structure theorem for finitely generated abelian groups)}\\
\\[\defaultaddspace]

Algebra IV & JKL & S. Lang & 
\parbox{6cm}{Introduction to Field \\ and Galois Theory}\\
\\[\defaultaddspace]

Analysis I &  MNO  & T. Apostol & 
\parbox{6cm}{Real numbers; Sequences and series;\\ Calculus of a single variable \\ (upto Taylor's Theorem)
} \\ 
\\[\defaultaddspace]

Analysis II &  PQR  & T. Apostol & 
\parbox{6cm}{Riemann integral; Introduction to \\ Calculus of several variables; \\ Metric spaces and elementary \\ topological notions on it} \\ 
\\[\defaultaddspace]

Analysis III &  \parbox{2cm}{STU}  & S. Dineen & 
\parbox{6cm}{\textbf{Vector Calculus}: multiple integrals, \\ Jacobian formula, line and surface \\ integrals, Green's, Stokes' and Gauss' (Divergence) theorems; \\ Sequences of functions; Weierstrass \\ approximation theorem} \\ 
\\[\defaultaddspace]

Analysis IV &  VWX  & Rudin & 
\parbox{6cm}{\textbf{Introduction to Function Spaces}:\\ compact metric spaces,\\ C([a,b]) as a complete metric space, \\ Banach's contraction principle, \\ Stone-Weierstrass and Arzela-Ascoli theorems, Fourier series } \\ 
\\[\defaultaddspace]

Probability Theory I &  YZ  & Chung; Feller & 
\parbox{6cm}{Combinatorial probability and urn models; Conditional probability; \\ Random variables; Expectation; \\ Moment generating functions;\\ Standard distributions(Binomial etc.); \\ Joint and conditional distributions; \\ Weak law of large numbers} \\ 
\\[\defaultaddspace]

Probability Theory II &  YZ  & Feller & 
\parbox{6cm}{Joint distributions; \\Transformation of variables\\(assuming Jacobian formula);\\ Distributions for sums, maxima/minima, order statistics, etc.; Standard multivariate and sampling distributions; Conditional expectation; Convergence of random variables} \\ 
\\[\defaultaddspace]

\bottomrule[2pt]

\end{tabular}

\end{document}

答え1

実際の問題は、ページ内にテーブルを配置するスペースが十分にないことです。

私が提案するのはこれです:

  1. テーブルを複数のページに分割する場合は、longtableの代わりに同じパッケージから を使用します。tabular

  2. この場合、表は1ページに収まります。geometryパッケージを使用して、表があるページのみのページの余白をコマンドで減らすことができます。

    \newgeometry{margin=2cm}
    

    後で通常のレイアウトに戻すには、

    \restoregeometry
    
  3. \defaultaddspaceの長さを短くする1pt

    \setlength{\defaultaddspace}{1pt}
    
  4. \parboxセルの内容を中央揃えにするために es を使用する必要はありません。パッケージをロードしての代わりにarrayを使用できます。新しい列タイプを宣言することもできます。mpM

    \newcolumntype{M}[1]{>{\raggedright\arraybackslash}m{#1}}
    

    \newlineセル内で改行を発行するためにも使用できます。

完全な例:

\documentclass[a4paper,10pt]{article}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsthm,array}
\usepackage{booktabs}

\usepackage{array,longtable}
\usepackage{lipsum} %only for the example

\newcolumntype{M}[1]{>{\raggedright\arraybackslash}m{#1}}
\setlength{\defaultaddspace}{1pt}

\begin{document}
\lipsum[1-5]

\newpage
\newgeometry{margin=2cm}
\begin{longtable}{p{2.5cm}p{2cm}lM{6cm}}
\toprule[2pt]
Name of Course & Instructor & Book(s) Referred & Brief List of Topics Covered \\
\hline
\\[\defaultaddspace]

Algebra I & ABC & Herstein; M. Artin &
Basic Set Theory; Group Theory\newline(upto Sylow theorems);\newline Introduction to Ring Theory \\
\\[\defaultaddspace]

Algebra II & DEF & Hoffman and Kunze &
Linear Algebra \newline(upto Spectral theorems) \\
\\[\defaultaddspace]

Algebra III & GHI & S. Lang &
Ring and Module Theory\newline(covering Hilbert basis theorem and structure theorem for finitely generated abelian groups) \\
\\[\defaultaddspace]

Algebra IV & JKL & S. Lang &
Introduction to Field \newline and Galois Theory\\
\\[\defaultaddspace]

Analysis I &  MNO  & T. Apostol &
Real numbers; Sequences and series;\newline Calculus of a single variable \newline (upto Taylor's Theorem) \\
\\[\defaultaddspace]

Analysis II &  PQR  & T. Apostol &
Riemann integral; Introduction to \newline Calculus of several variables; \newline Metric spaces and elementary \newline topological notions on it \\
\\[\defaultaddspace]

Analysis III &  \parbox{2cm}{STU}  & S. Dineen &
\textbf{Vector Calculus}: multiple integrals, \newline Jacobian formula, line and surface \newline integrals, Green's, Stokes' and Gauss' (Divergence) theorems; \newline Sequences of functions; Weierstrass \newline approximation theorem \\
\\[\defaultaddspace]

Analysis IV &  VWX  & Rudin &
\textbf{Introduction to Function Spaces}:\newline compact metric spaces,\newline C([a,b]) as a complete metric space, \newline Banach's contraction principle, \newline Stone-Weierstrass and Arzela-Ascoli theorems, Fourier series \\
\\[\defaultaddspace]

Probability Theory I &  YZ  & Chung; Feller &
Combinatorial probability and urn models; Conditional probability; \newline Random variables; Expectation; \newline Moment generating functions;\newline Standard distributions(Binomial etc.); \newline Joint and conditional distributions; \newline Weak law of large numbers \\
\\[\defaultaddspace]

Probability Theory II &  YZ  & Feller &
Joint distributions; \newline Transformation of variables\newline(assuming Jacobian formula);\newline Distributions for sums, maxima/minima, order statistics, etc.; Standard multivariate and sampling distributions; Conditional expectation; Convergence of random variables \\
\\[\defaultaddspace]

\bottomrule[2pt]

\end{longtable}

\newpage
\restoregeometry
\lipsum[1-5]

\end{document} 

出力:

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


編集

egreg がコメントで指摘しているように、おそらく、beforepを追加せずに通常の列を使用すると、表の見栄えが良くなります。\\\\[\defaultaddspace]

これは別の可能性です (最も気に入ったものを選択してください):

\documentclass[a4paper,10pt]{article}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsthm,array}
\usepackage{booktabs}

\usepackage{array,longtable}
\usepackage{lipsum} %only for the example

\begin{document}
\lipsum[1-5]

\newpage
\newgeometry{margin=3cm}
\begin{longtable}{p{2.5cm}p{2cm}lp{6cm}}
\toprule[2pt]
Name of Course & Instructor & Book(s) Referred & Brief List of Topics Covered \\[\defaultaddspace]
\hline
\\

Algebra I & ABC & Herstein; M. Artin &
Basic Set Theory; Group Theory\newline(upto Sylow theorems);\newline Introduction to Ring Theory \\[\defaultaddspace]

Algebra II & DEF & Hoffman and Kunze &
Linear Algebra \newline(upto Spectral theorems) \\[\defaultaddspace]

Algebra III & GHI & S. Lang &
Ring and Module Theory\newline(covering Hilbert basis theorem and structure theorem for finitely generated abelian groups) \\[\defaultaddspace]

Algebra IV & JKL & S. Lang &
Introduction to Field \newline and Galois Theory \\[\defaultaddspace]

Analysis I &  MNO  & T. Apostol &
Real numbers; Sequences and series;\newline Calculus of a single variable \newline (upto Taylor's Theorem) \\[\defaultaddspace]

Analysis II &  PQR  & T. Apostol &
Riemann integral; Introduction to \newline Calculus of several variables; \newline Metric spaces and elementary \newline topological notions on it \\[\defaultaddspace]

Analysis III &  \parbox{2cm}{STU}  & S. Dineen &
\textbf{Vector Calculus}: multiple integrals, \newline Jacobian formula, line and surface \newline integrals, Green's, Stokes' and Gauss' (Divergence) theorems; \newline Sequences of functions; Weierstrass \newline approximation theorem \\[\defaultaddspace]

Analysis IV &  VWX  & Rudin &
\textbf{Introduction to Function Spaces}:\newline compact metric spaces,\newline C([a,b]) as a complete metric space, \newline Banach's contraction principle, \newline Stone-Weierstrass and Arzela-Ascoli theorems, Fourier series \\[\defaultaddspace]

Probability Theory I &  YZ  & Chung; Feller &
Combinatorial probability and urn models; Conditional probability; \newline Random variables; Expectation; \newline Moment generating functions;\newline Standard distributions(Binomial etc.); \newline Joint and conditional distributions; \newline Weak law of large numbers \\[\defaultaddspace]

Probability Theory II &  YZ  & Feller &
Joint distributions; \newline Transformation of variables\newline(assuming Jacobian formula);\newline Distributions for sums, maxima/minima, order statistics, etc.; Standard multivariate and sampling distributions; Conditional expectation; Convergence of random variables \\[\defaultaddspace]

\bottomrule[2pt]

\end{longtable}

\newpage
\restoregeometry
\lipsum[1-5]

\end{document} 

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

答え2

表が 1 ページに収まると仮定して、次の操作を実行することをお勧めします。

  • tabularx環境の代わりに環境を使用しtabular、その幅を に設定し\textwidthX最後の列に列タイプを使用します。これにより、最後の列の幅が (他の 3 つの列の幅を引いた値) に設定されます\textwidth

  • 最終列で完全な両端揃えではなく、不規則な右揃えの組版を使用します。ragged2e不規則な右揃えモードで組版された単語のハイフネーションを許可するには、パッケージをロードします。

  • さまざまなラッパーを削除し\parbox\newlineステートメントを使用して列 4 で改行を誘発します。 (@egreg さん、ありがとうございます!)

  • 多くの\\ \\[\defaultaddspace]命令を に置き換えます\\[\defaultaddspace]。 によって提供されるものよりも多くの垂直方向の空白が本当に必要な場合は\defaultaddspace、そのパラメータの値を適切に増やすだけです。以下の例では、 を使用して、2.5\defaultaddspace代数および解析コースのグループの後に垂直方向のスペースを増やしています。

1in周囲に余白があると仮定すると、次のようになります。

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

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,booktabs}
\usepackage{tabularx,ragged2e}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X}

\begin{document}
\noindent
\begin{tabularx}{\textwidth}{@{} l p{1.75cm} l Y @{}} 
\toprule[2pt] 
Name of Course & Instructor & Book(s) Referred & Brief List of Topics Covered \\ 
\midrule

Algebra I & ABC & Herstein; M. Artin & 
Basic Set Theory; Group Theory\newline
(upto Sylow theorems);\newline
Introduction to Ring Theory \\[\defaultaddspace]

Algebra II & DEF & Hoffman and Kunze & 
Linear Algebra \newline
(upto Spectral theorems) \\[\defaultaddspace]

Algebra III & GHI & S. Lang & 
Ring and Module Theory \newline
(covering Hilbert basis theorem and structure theorem for finitely generated 
abelian groups)\\[\defaultaddspace]

Algebra IV & JKL & S. Lang & 
Introduction to Field and Galois Theory \\[2.5\defaultaddspace]

Analysis I &  MNO  & T. Apostol & 
Real numbers; Sequences and series;\newline
Calculus of a single variable \newline
(upto Taylor's Theorem) \\[\defaultaddspace]

Analysis II &  PQR  & T. Apostol & 
Riemann integral; Introduction to Calculus of several variables; \newline 
Metric spaces and elementary topological notions on it \\[\defaultaddspace]

Analysis III &  STU  & S. Dineen & 
\textbf{Vector Calculus}: multiple integrals, Jacobian formula, line and 
surface integrals, Green's, Stokes' and Gauss' (Divergence) theorems; \newline
Sequences of functions; \newline
Weierstrass approximation theorem \\[\defaultaddspace]

Analysis IV &  VWX  & Rudin & 
\textbf{Introduction to Function Spaces}:\newline
compact metric spaces, $C([a,b])$ as a complete metric space, Banach's contraction principle, 
 Stone-Weierstrass and Arzela-Ascoli theorems, Fourier series \\[2.5\defaultaddspace]

Prob.\ Theory I &  YZ  & Chung; Feller & 
Combinatorial probability and urn models; Conditional probability; \newline
Random variables; Expectation; \newline
Moment generating functions;\newline
Standard distributions (Binomial etc.); \newline
Joint and conditional distributions; \newline
Weak law of large numbers \\[\defaultaddspace]

Prob.\ Theory II &  YZ  & Feller & 
Joint distributions; \newline
Transformation of variables (assuming Jacobian formula);\newline
Distributions for sums, maxima\slash minima, order statistics, etc.;\newline
Standard multivariate and sampling distributions;\newline 
Conditional expectation; \newline
Convergence of random variables \\

\bottomrule[2pt]
\end{tabularx}
\end{document}

補遺: この設定を拡張して、テーブルを複数のページにまたがるようにするのは簡単です。まず、(i)ロングテーブルそしてltxtableパッケージ(パッケージに加えてtabularx)をプリアンブルに追加し、(ii)テーブルのヘッダー/フッター構造を次のlongtable構文に準拠するように変更します。

  • まず、現在のテーブルの内容全体(から\begin{tabularx}{\textwidth}{...}まで\end{tabularx})を別のファイルこのファイルを、たとえば と呼びますmybiglongtable.tex。(もっと適切な名前が思いつくと思いますが...)

  • 「ドライバーファイル」に、命令を挿入します

    \LTXtable{\textwidth}{mybiglongtable.tex} % note explicit width indication
    

    テーブルを開始したい場所のすぐ近くです。(A はlongtableLaTeX の意味での「浮動オブジェクト」ではありません。) 前述の単一ページのテーブルの例のドライバー ファイルは次のようになります。

    \documentclass[a4paper,10pt]{article}
    \usepackage[utf8]{inputenc}
    \usepackage[margin=1in]{geometry}
    \usepackage{amsmath,amsthm,booktabs}
    \usepackage{tabularx,longtable,ltxtable,ragged2e}
    \newcolumntype{Y}{>{\RaggedRight\arraybackslash}X}
    \begin{document}
    \LTXtable{\textwidth}{mybiglongtable.tex}
    \end{document}
    
  • ファイルでmybiglongtable.tex、次の変更を加えます。

    • 変化

      \begin{tabularx}{\textwidth}{@{} l p{1.75cm} l Y @{}}
      

      \begin{longtable}{@{} l p{1.75cm} l Y @{}} % no explicit width indication
      

      そして、\end{tabularx}(ファイルの末尾で) を に変更します\end{longtable}

    • 構文を使用してlongtable、 の直後に必要なヘッダーとフッターの情報を指定します\begin{longtable}{...}。次のように指定します。

      \toprule[2pt] 
      Name of Course & Instructor & Book(s) Referred & Brief List of Topics Covered \\ 
      \midrule
      \endfirsthead
      \multicolumn{4}{@{}l}{\emph{Continued from previous page}}\\
      \midrule[\heavyrulewidth]
      \endhead
      \midrule[\heavyrulewidth]
      \multicolumn{4}{r@{}}{\emph{Continued on following page}}
      \endfoot
      \bottomrule[2pt]
      \endlastfoot
      

      表の上部と下部のすべての罫線描画コマンドは\endfirsthead、、、、およびの\endheadいずれかのコマンドに割り当てられていることに注意してください。\endfoot\endlastfoot

    • ファイルの残りの部分 ( まで\end{longtable}) には、テーブルの「本体」、つまりコースに関連する情報を含める必要があります。以前の MWE と同様に と を使用して、\\[\defaultaddspace]コンテンツ\\[2.5\defaultaddspace]を視覚的にグループ化することができます。

関連情報