centralizando uma legenda sob uma mesa

centralizando uma legenda sob uma mesa

Tenho uma tabela com duas colunas e 12 linhas. Exijo que a tabela apareça no lado esquerdo da página (o que posso fazer), porém a legenda fica centralizada na página. Gostaria de colocar a legenda embaixo da mesa e centralizá-la embaixo da mesa. A saída é mostrada abaixo.insira a descrição da imagem aqui

\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}

Responder1

Aqui está um caminho (já que você já deseja [H]a opção e carregou o captionpacote, suponho que estará tudo bem para você):

\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}

insira a descrição da imagem aqui

Responder2

Como o material tabular deve ser digitado alinhado à esquerda (também conhecido como irregular à direita), acho que a legenda ficaria melhor se também estivesse alinhada à esquerda. (No entanto, veja abaixo uma solução diferente.) Pode-se atingir esse objetivo de formatação carregando o captionpacote com as opções singlelinecheck=falsee justification=raggedright.

insira a descrição da imagem aqui

\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}

Alternativamente, se a legendadeveser centralizado abaixo do tabularmaterialeo tabularmaterial deve ser composto à esquerda, sugiro que você (a) execute \captionsetup{justification=centering}, (b) carregue omesa de três partespacote e (c) encerrar tanto o tabularambiente quanto a \captioninstrução em um threeparttableambiente. Esta configuração permite que o LaTeX meça a largura do tabularmaterial e centralize a legenda abaixo da tabular; se necessário, o LaTeX irá inserir automaticamente quebras de linha na legenda. Esse comportamento é mostrado na captura de tela a seguir.

insira a descrição da imagem aqui

\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}

informação relacionada