表の下にキャプションを中央に配置する

表の下にキャプションを中央に配置する

2 列 12 行の表があります。表をページの左側に表示する必要がありますが (これは可能です)、キャプションがページの中央に配置されています。キャプションを表の下に配置して、表の下に中央配置したいと思います。出力を以下に示します。ここに画像の説明を入力してください

\documentclass[12pt,english]{article}
\usepackage{caption}
\begin{document}
 \begin{table}[H]
 \begin{tabular}{|c|>{\centering}p{2cm}|}
 \hline 
  Year & Population (millions)\tabularnewline
  \hline 
   $1900$ & $1650$\tabularnewline
   $1910$ & $1750$\tabularnewline
   $1920$ & $1860$\tabularnewline
   $1930$ & $2070$\tabularnewline
   $1940$ & $2300$\tabularnewline
   $1950$ & $2560$\tabularnewline
   $1960$ & $3040$\tabularnewline
   $1970$ & $3710$\tabularnewline
   $1980$ & $4450$\tabularnewline
   $1990$ & $5280$\tabularnewline
   $2000$ & $6070$\tabularnewline
   \hline 
  \end{tabular}
  \raggedright{}\caption{World Population}\label{table1}
  \end{table}
 \end{document}

答え1

方法は次のとおりです (すでに[H]オプションが必要で、パッケージをロードしているのでcaption、問題ないと思います):

\documentclass[12pt,english]{article}
\usepackage{caption}
\usepackage{array}
\begin{document}
 % A \noindent is possibly needed here as @Mico suggested in his comment
 \noindent\begin{minipage}{0.35\textwidth}
 \centering
 \begin{tabular}{|c|>{\centering}p{2cm}|}
 \hline 
  Year & Population (millions)\tabularnewline
  \hline 
   $1900$ & $1650$\tabularnewline
   $1910$ & $1750$\tabularnewline
   $1920$ & $1860$\tabularnewline
   $1930$ & $2070$\tabularnewline
   $1940$ & $2300$\tabularnewline
   $1950$ & $2560$\tabularnewline
   $1960$ & $3040$\tabularnewline
   $1970$ & $3710$\tabularnewline
   $1980$ & $4450$\tabularnewline
   $1990$ & $5280$\tabularnewline
   $2000$ & $6070$\tabularnewline
   \hline 
  \end{tabular}
  \captionof{table}{World Population}\label{table1}
  \end{minipage}
 \end{document}

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

答え2

表形式の資料は左揃え (つまり、右揃え) でタイプセットする必要があるため、キャプションも左揃えにすると見栄えが良くなると思います。 (ただし、別の解決策については以下を参照してください。) このフォーマットの目的は、captionオプションとを使用してパッケージsinglelinecheck=falseをロードすることで達成できますjustification=raggedright

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

\documentclass[12pt,english]{article}
\usepackage{array,caption}
\captionsetup{singlelinecheck=false,justification=raggedright}
\begin{document}
\begin{table}[ht!]
 \begin{tabular}{|c|>{\centering\arraybackslash}p{2cm}|}
 \hline 
   Year & Population (millions)\\ \hline 
   $1900$ & $1650$\\
   $1910$ & $1750$\\
   $1920$ & $1860$\\
   $1930$ & $2070$\\
   $1940$ & $2300$\\
   $1950$ & $2560$\\
   $1960$ & $3040$\\
   $1970$ & $3710$\\
   $1980$ & $4450$\\
   $1990$ & $5280$\\
   $2000$ & $6070$\\ 
 \hline 
 \end{tabular}
\caption{World Population}\label{table1}
\end{table}
\end{document}

あるいは、キャプションがしなければならないtabular素材の下に中央に配置するそして資料tabularは左揃えでタイプセットする必要があるので、(a) を実行し\captionsetup{justification=centering}、(b) をロードすることをお勧めします。3つの部分から成るテーブルパッケージ、および (c)tabular環境と\captionステートメントの両方を環境内に含めますthreeparttable。この設定により、LaTeX は資料の幅を測定しtabular、表の下にキャプションを中央に配置できます。必要に応じて、LaTeX はキャプションに自動的に改行を挿入します。この動作は次のスクリーンショットに示されています。

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

\documentclass[12pt,english]{article}
\usepackage{array,caption,threeparttable}
\captionsetup{justification=centering}
\begin{document}
\begin{table}[ht!]
\begin{threeparttable}
 \begin{tabular}{|c|>{\centering\arraybackslash}p{2cm}|}
 \hline 
   Year & Population (millions)\\ \hline 
   $1900$ & $1650$\\
   $1910$ & $1750$\\
   $1920$ & $1860$\\
   $1930$ & $2070$\\
   $1940$ & $2300$\\
   $1950$ & $2560$\\
   $1960$ & $3040$\\
   $1970$ & $3710$\\
   $1980$ & $4450$\\
   $1990$ & $5280$\\
   $2000$ & $6070$\\ 
 \hline 
 \end{tabular}
\caption{World Population}\label{table1}
\end{threeparttable}
\end{table}
\end{document}

関連情報