
Quero localizar a mesa da imagem exatamente no centro. neste momento, ele se projeta para a direita e parece feio. Este é o código que tenho:
\scalebox{0.75}{
\begin{center}
\centering
\begin{tabular}{||c c c c c c c c c c||}
\hline
& SHSZ300 & RGUSHS & SPTRHLTH & MVGDXJTR & SX6R & GDLECFEF & NDELCHF &
SXXR & SPTRINFT \\ [0.5ex]
\hline\hline
SHSZ300&1.0000&0.1256&0.1231&0.1806&0.1800&0.4097&0.5796&0.2387&0.2593\\
\hline
RGUSHS&0.1256&1.0000&0.7845&0.1667&0.3758&0.5186&0.3488&0.5881&0.5926\\
\hline
SPTRHLTH&0.1231&0.7845&1.0000&0.1229&0.5322&0.6021&0.4604&0.6867&0.6586\\
\hline
MVGDXJTR&0.1806&0.1667&0.1229&1.0000&0.0734&0.1163&0.3502&0.1841&0.1900\\
\hline
SX6R&0.1800&0.3758&0.5322&0.0734&1.0000&0.5312&0.3054&0.7212&0.5611\\
\hline
GDLECFEF&0.4097&0.5186&0.6021&0.1163&0.5312&1.0000&0.7493&0.7267&0.6943\\
\hline
NDELCHF&0.5796&0.3488&0.4604&0.3502&0.3054&0.7493&1.0000&0.5453&0.5386\\
\hline
SXXR&0.2387&0.5881&0.6867&0.1841&0.7212&0.7267&0.5453&1.0000&0.7182\\
\hline
SPTRINFT&0.2593&0.5926&0.6586&0.1900&0.5611&0.6943&0.5386&0.7182&1.0000\\
\end{tabular}
\end{center}}
Como posso modificar o código para que a tabela fique exatamente centralizada?
Responder1
eu redesenharia sua tabela da seguinte maneira:
- explorar o fato de que os cabeçalhos de linha e os cabeçalhos de coluna são iguais
- usar
tabular*
para ambiente de mesa - definido
tabsep
para ocupar o espaço disponível entre colunas - não use linhas verticais
- não usar
\scalebox
- para linhas horizontais
booktabs
pacote empoy
(linhas vermelhas indicam borda do texto)
\documentclass{article}
\usepackage{geometry}
\usepackage{booktabs}
%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\begin{document}
\begin{table}%[htb]
\setlength\tabcolsep{0pt}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
l
*{9}{c}
}
\toprule
& (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) & (9) \\
\midrule
(1): SHSZ300 &1.0000 &0.1256 &0.1231&0.1806&0.1800&0.4097&0.5796&0.2387&0.2593\\
(2): RGUSHS &0.1256 &1.0000 &0.7845&0.1667&0.3758&0.5186&0.3488&0.5881&0.5926\\
(3): SPTRHLTH &0.1231 &0.7845 &1.0000&0.1229&0.5322&0.6021&0.4604&0.6867&0.6586\\
\addlinespace
(4): MVGDXJTR &0.1806 &0.1667 &0.1229&1.0000&0.0734&0.1163&0.3502&0.1841&0.1900\\
(5): SX6R &0.1800 &0.3758 &0.5322&0.0734&1.0000&0.5312&0.3054&0.7212&0.5611\\
(6): GDLECFEF &0.4097 &0.5186 &0.6021&0.1163&0.5312&1.0000&0.7493&0.7267&0.6943\\
\addlinespace
(7): NDELCHF &0.5796 &0.3488 &0.4604&0.3502&0.3054&0.7493&1.0000&0.5453&0.5386\\
(8): SXXR &0.2387 &0.5881 &0.6867&0.1841&0.7212&0.7267&0.5453&1.0000&0.7182\\
(9): SPTRINFT &0.2593 &0.5926 &0.6586&0.1900&0.5611&0.6943&0.5386&0.7182&1.0000\\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
observação: como o layout da página do seu documento não é conhecido, presumo que a página tenha A4
bordas conforme o padrão determinado pelo geometry
pacote. se a largura do texto for menor, talvez seja necessário reduzir o tamanho da fonte para \small
ou footnotesize
.
Responder2
Aqui está uma variaçãoResposta de @Zarko(e tambémesta resposta) que vai além na redução da confusão visual: ele emprega o siunitx
pacote para exibir apenas 3 dígitos significativos para todas as correlações. Acho que você estará fazendo um grande favor aos seus leitores ao aplicar tal simplificação.
\documentclass{article}
\usepackage{booktabs,siunitx}
\begin{document}
\begin{table}[htb]
\sisetup{round-mode = places,
round-precision = 3,
table-format = 1.3}
\setlength\tabcolsep{0pt}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} l *{9}{S} }
\toprule
& {(1)} & {(2)} & {(3)} & {(4)} & {(5)} & {(6)} & {(7)} & {(8)} & {(9)} \\
\midrule
(1) SHSZ300 & 1.0000 & 0.1256 & 0.1231& 0.1806& 0.1800& 0.4097& 0.5796& 0.2387& 0.2593\\
(2) RGUSHS & 0.1256 & 1.0000 & 0.7845& 0.1667& 0.3758& 0.5186& 0.3488& 0.5881& 0.5926\\
(3) SPTRHLTH& 0.1231 & 0.7845 & 1.0000& 0.1229& 0.5322& 0.6021& 0.4604& 0.6867& 0.6586\\
\addlinespace
(4) MVGDXJTR& 0.1806 & 0.1667 & 0.1229& 1.0000& 0.0734& 0.1163& 0.3502& 0.1841& 0.1900\\
(5) SX6R & 0.1800 & 0.3758 & 0.5322& 0.0734& 1.0000& 0.5312& 0.3054& 0.7212& 0.5611\\
(6) GDLECFEF& 0.4097 & 0.5186 & 0.6021& 0.1163& 0.5312& 1.0000& 0.7493& 0.7267& 0.6943\\
\addlinespace
(7) NDELCHF & 0.5796 & 0.3488 & 0.4604& 0.3502& 0.3054& 0.7493& 1.0000& 0.5453& 0.5386\\
(8) SXXR & 0.2387 & 0.5881 & 0.6867& 0.1841& 0.7212& 0.7267& 0.5453& 1.0000& 0.7182\\
(9) SPTRINFT& 0.2593 & 0.5926 & 0.6586& 0.1900& 0.5611& 0.6943& 0.5386& 0.7182& 1.0000\\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
Responder3
Usar o \small
tamanho da fonte, reduzir o valor \tabcolsep
e usar cabeçalhos de colunas multilinhas quando necessário com o comando \makecell
ou \thead
são as ferramentas usuais para fazer uma tabela se ajustar à largura da página. Além disso, carreguei hhline
para ter interseções mais organizadas de regras verticais e horizontais:
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage[utf8]{inputenc}%
\usepackage{makecell, hhline}
\begin{document}
\begin{table}[!htb]
\centering\small
\setlength{\extrarowheight}{2pt}
\setlength{\tabcolsep}{3pt}
\begin{tabular}{||*{10}{c}||}
\hline
& SHSZ300 & RGUSHS & \makecell{SPTRH\\LTH} & \makecell{MVGDXJ\\TR} & SX6R & \makecell{GDLECF\\EF} & \makecell{NDELC\\HF} &
SXXR & \makecell{SPTRIN\\FT} \\ [0.5ex]
\hhline{}
SHSZ300&1.0000&0.1256&0.1231&0.1806&0.1800&0.4097&0.5796&0.2387&0.2593\\
\hhline{||*{10}{=}||}
RGUSHS&0.1256&1.0000&0.7845&0.1667&0.3758&0.5186&0.3488&0.5881&0.5926\\
\hhline{||*{10}{=}||}
SPTRHLTH&0.1231&0.7845&1.0000&0.1229&0.5322&0.6021&0.4604&0.6867&0.6586\\
\hhline{||*{10}{=}||}
MVGDXJTR&0.1806&0.1667&0.1229&1.0000&0.0734&0.1163&0.3502&0.1841&0.1900\\
\hhline{||*{10}{=}||}
SX6R&0.1800&0.3758&0.5322&0.0734&1.0000&0.5312&0.3054&0.7212&0.5611\\
\hhline{||*{10}{=}||}
GDLECFEF&0.4097&0.5186&0.6021&0.1163&0.5312&1.0000&0.7493&0.7267&0.6943\\
\hhline{||*{10}{=}||}
NDELCHF&0.5796&0.3488&0.4604&0.3502&0.3054&0.7493&1.0000&0.5453&0.5386\\
\hhline{||*{10}{=}||}
SXXR&0.2387&0.5881&0.6867&0.1841&0.7212&0.7267&0.5453&1.0000&0.7182\\
\hhline{||*{10}{=}||}
SPTRINFT&0.2593&0.5926&0.6586&0.1900&0.5611&0.6943&0.5386&0.7182&1.0000\\
\end{tabular}
\end{table}
\end{document}