我正在尝试将标签“Registro”和“Datos faltantes”对齐到中心(水平)。我使用了 \begin(center) Registro \end(center) 和 \ centering(Registro),但没有成功。有人能帮我吗?谢谢
这是我的代码:
\documentclass[12pt,letterpaper,openany,spanish]{book}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage[left=2.3cm,right=2.3cm,top=2.1cm,bottom=2.3cm]{geometry}
\usepackage{amsmath, amsthm, amssymb} % Paquetes matemáticos
\usepackage[utf8]{inputenc} % Codificación .tex
\usepackage{booktabs,siunitx}
\usepackage{graphicx}
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{graphicx} % Para insertar imágenes
\usepackage{lipsum} % Para texto falso
\usepackage{caption}
\begin{document}
\begin{table}[h]
\centering
\captionsetup{singlelinecheck = false, justification=justified,margin=0 mm}
\caption{Características}
\footnotesize{
\begin{tabular}{p{0.6 in}p{1.3in}p{0.8in}p{0.6in}p{2.1in}}
\toprule[1.8pt] \\[-10pt]
\multirow{2}[3]{*}{\textbf{Estación}} &
\multicolumn{1}{c}{\textbf{Ubicación}} &
\multirow{2}[3]{*}{\textbf{Profundidad}} &
\multirow{2}{*}{{\textbf{Registro}}} &
\multirow{2}[3]{*}{\textbf{Datos faltantes}} \\[0.1cm] \cmidrule(lr){2-2}
\\[-0.3cm]
\multicolumn{1}{c}{} &
\multicolumn{1}{c}{\textbf{Latitud Longitud}} &
\multicolumn{1}{c}{\textbf{(m)}} &
\multicolumn{1}{c}{\textbf{(mes/día/año)}} &
\multicolumn{1}{c}{\textbf{(mes/día/año)}}
\\
\midrule[1pt] \\ [-0.4cm]
\multicolumn{5}{c}{{Nivel del mar}}\\ [0.1cm]
\hline \\ [-0.3cm]
\textsc{m. aca} $^{1}$ & & \centering{$ ^{4}$} & mm/dd/aaaa &
\\[0.3cm]
\textsc{m. mzn} $^{2}$ & & \centering{$ ^{4}$} & mm/dd/aaaa &
\\[0.3cm]
\textsc{m. zht} $^{3}$ & & \centering{$ ^{4}$} & mm/dd/aaaa &
\\[0.1cm]
\bottomrule[1pt]
\end{tabular}}
\end{table}
\end{document}
答案1
我建议使用该包简化以下代码makecell
:
\documentclass[12pt,letterpaper,openany,spanish]{book}
\usepackage[spanish]{babel}
\usepackage[left=2.3cm,right=2.3cm,top=2.1cm,bottom=2.3cm]{geometry}
\usepackage{amsmath, amsthm, amssymb} % Paquetes matemáticos
\usepackage{booktabs,siunitx}
\usepackage{graphicx}
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{graphicx} % Para insertar imágenes
\usepackage{lipsum} % Para texto falso
\usepackage{caption}
\usepackage{makecell}
\renewcommand{\theadfont}{\small\bfseries}
\begin{document}
\begin{table}[h]
\centering
\captionsetup{singlelinecheck = false, justification=justified,margin=0 mm}
\caption{Características}
\footnotesize{
\begin{tabular}{p{0.6 in}p{1.3in}p{0.8in}p{0.6in}p{2.1in}}
\toprule[1.8pt]\addlinespace[-1.5ex]
\thead{Estación } & \thead{Ubicación \\ Latitud Longitud} & \thead{Profundidad \\ (m)}
& \thead{Registro \\ (mes/día/año)} & \thead[t]{ \\ Datos faltantes \\ (mes/día/año)}
\\ \midrule[1pt]%
\multicolumn{5}{c}{{Nivel del mar}}\\ [0.1cm]
\hline \\ [-0.3cm]
\textsc{m. aca} $^{1}$ & & \centering{$ ^{4}$} & mm/dd/aaaa &
\\[0.3cm]
\textsc{m. mzn} $^{2}$ & & \centering{$ ^{4}$} & mm/dd/aaaa &
\\[0.3cm]
\textsc{m. zht} $^{3}$ & & \centering{$ ^{4}$} & mm/dd/aaaa &
\\[0.1cm]
\bottomrule[1pt]
\end{tabular}}
\end{table}
\end{document}
答案2
- 对于您的表,您可以使用
tabularray
带有库的包amsmath
,booktabs
和siunitx
。 - 对于表中以指数形式写出的数字,我猜它们是用于表格注释的,因此在下面的 MWE 中使用了表格环境
talltblr
(这tabularray
相当于threeparttable
):
\documentclass[12pt,letterpaper,openany,spanish]{book}
\usepackage{babel}
\usepackage[hmargin=2.3cm,vmargin={2.1cm,2.3cm}]{geometry}
\usepackage{amsthm, amssymb} % Paquetes matemáticos
\usepackage{tabularray}
\UseTblrLibrary{amsmath, booktabs, siunitx}
\usepackage{graphicx} % Para insertar imágenes
\usepackage[skip=1ex,
justification=justified,
singlelinecheck=false]{caption}
\usepackage{lipsum} % Para texto falso
\begin{document}
\begin{table}[h]
\caption{Características}
\label{tab:?}
\centering
\small
\DefTblrTemplate{caption}{default}{}
\SetTblrStyle{note}{font=\footnotesize}
\begin{talltblr}[
label=none,
note{1} = {description},
note{2} = {description},
note{3} = {description},
note{4} = {description},
]{
colsep=4pt,
colspec = {@{} Q[l, m] *{4}{X[c, m]} @{}},
cell{3-Z}{1} = {font=\scshape},
row{1} = {font=\footnotesize\bfseries}
}
\toprule
Estación & {Ubicación\\ Latitud Longitud}
& {Profundidad\\ (m)}
& Registro (mes/día/año)
& Datos faltantes (mes/día/año) \\
\midrule
\SetCell[c=5]{c} Nivel del mar
& & & & \\
\midrule[0.8pt]
m. aca \TblrNote{1} & & \TblrNote{4} & mm/dd/aaaa & \\
m. mzn \TblrNote{2} & & \TblrNote{4} & mm/dd/aaaa & \\
m. zht \TblrNote{3} & & \TblrNote{4} & mm/dd/aaaa & \\
\bottomrule
\end{talltblr}
\end{table}
\end{document}