我現在正在開始使用 LaTeX,我的表格標題有問題。我正在使用 TabularX,標題與表格本身一起剪裁。你能幫我嗎?謝謝你!
我真的很抱歉,程式碼的格式似乎不起作用,我不知道為什麼。
\documentclass[
paper=a4,
fontsize=11pt,
parskip=half*,
]{scrartcl}
\begin{document}
\usepackage{tabularx}
\usepackage[labelfont={bf},
font={footnotesize},
labelsep=space,
format=hang,
justification=raggedright,
singlelinecheck=false
]{caption}
\captionsetup[table]{aboveskip=5pt, belowskip=-5pt}
\begin{table}[!ht]
\small
\centering
\captionof{table}[RFA-Analyseergebnisse des ausgefilterten Feststoff (Partikelretention 8-15µm)]{RFA-Analyseergebnisse des ausgefilterten Feststoff (Partikelretention 8-15µm)}
\begin{tabular}{ccccccccc}
\hline
\textbf{Al} & \textbf{Ni} & \textbf{Co} & \textbf{Mn} & \textbf{Cu} & \textbf{Fe} & \textbf{P} & \textbf{Ca} & \textbf{Si} \\ \hline
10.49\% & 22.68\% & 11.74\% & 6.65\% & 1.29\% & 0.85\% & 0.79\% & 0.36\% & 0.22\% \\ \hline
\end{tabular}
\label{RFA_Filterkuchen_1}
\end{table}
\end{document}
答案1
除了擺脫有問題的belowskip=-5pt
選項之外,您確實應該嘗試給您的桌子一個更開放和誘人的“外觀”。我建議您透過(a)使用套件的巨集booktabs
來建立間隔良好的水平線,(b)不要這樣做粗體字標題行中的項目(並使用諸如mhchem
排版化學方程式之類的套件),以及(c)將通用%
符號從資料單元移到標題中。
順便說一句,鑑於該指令發生在table
環境中,我不清楚為什麼您要使用\captionof{table}{...}
而不是僅僅使用\caption{...}
.
\documentclass[
paper=a4,
fontsize=11pt,
parskip=half*,
]{scrartcl}
%\usepackage{tabularx} % does not appear to be needed
\usepackage[font={footnotesize}, % you sure about this?
labelfont = bf,
labelsep = space,
format = hang,
justification=raggedright,
singlelinecheck=false
]{caption}
\captionsetup[table]{skip=0.5\baselineskip}
% {aboveskip=5pt, belowskip=-5pt} % huh?
\usepackage{siunitx,mhchem,booktabs}
\begin{document}
\begin{table}[htb]
\centering
\small
\caption{RFA-Analyseergebnisse des ausgefilterten
Feststoffs (Partikelretention
8--15\,\unit{\micro\meter}), in \%}
\label{RFA_Filterkuchen_1}
\begin{tabular}{@{} *{9}{c} @{}}
\toprule
\ce{Al} & \ce{Ni} & \ce{Co} & \ce{Mn} & \ce{Cu} &
\ce{Fe} & \ce{P} & \ce{Ca} & \ce{Si} \\
\midrule
10.49 & 22.68 & 11.74 & 6.65 & 1.29 &
0.85 & 0.79 & 0.36 & 0.22 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
我認為你應該將belowskip
參數從更改-5pt
為5pt
。但是,您可以僅用於\caption
表格。
另外,我建議你(作為初學者)使用這個婚禮網站輕鬆建立表格
\documentclass[
paper=a4,
fontsize=11pt,
parskip=half*,
]{scrartcl}
\usepackage{tabularx}
\usepackage[labelfont={bf},
font={footnotesize},
labelsep=space,
format=hang,
justification=raggedright,
singlelinecheck=false
]{caption}
%\captionsetup[table]{aboveskip=5pt, belowskip=5pt} % <--
\begin{document}
\begin{center}
\begin{table}[!ht]
\small
\caption{RFA-Analyseergebnisse des ausgefilterten Feststoff (Partikelretention 8-15µm)}
\begin{tabular}{ccccccccc}
\hline
\textbf{Al} & \textbf{Ni} & \textbf{Co} & \textbf{Mn} & \textbf{Cu} & \textbf{Fe} & \textbf{P} & \textbf{Ca} & \textbf{Si} \\ \hline
10.49\% & 22.68\% & 11.74\% & 6.65\% & 1.29\% & 0.85\% & 0.79\% & 0.36\% & 0.22\% \\ \hline
\end{tabular}
\label{RFA_Filterkuchen_1}
\end{table}
\end{center}
\end{document}
答案3
使用{NiceTabular}
ofnicematrix
及其內建密鑰caption
。
\documentclass[
paper=a4,
fontsize=11pt,
parskip=half*,
]{scrartcl}
\usepackage{nicematrix,booktabs}
\begin{document}
\begin{table}[!ht]
\small
\centering
\begin{NiceTabular}
[ caption = { RFA-Analyseergebnisse des ausgefilterten Feststoff (Partikelretention 8-15µm) } ]
{@{}ccccccccc@{}}
\toprule
\RowStyle[bold]{}
Al & Ni & Co & Mn & Cu & Fe & P & Ca & Si \\
\midrule
10.49\% & 22.68\% & 11.74\% & 6.65\% & 1.29\% & 0.85\% & 0.79\% & 0.36\% & 0.22\% \\
\bottomrule
\end{NiceTabular}
\label{RFA_Filterkuchen_1}
\end{table}
\end{document}
答案4
我會用以下方式寫你的表:
- 對於表使用帶列
tabularray
的包X[c]
booktabs
對於包裝的表格行規則- 在第二行中,我將按照 package 中的建議將資料寫入數量
siunitx
。包booktabs
並siunitx
作為庫加載tabularray
:
\documentclass[paper=a4,
fontsize=11pt,
parskip=half*,
]{scrartcl}
\usepackage[skip=1ex,
font={footnotesize},
labelfont=bf,
labelsep=space,
format=hang,
justification=raggedright,
singlelinecheck=false
]{caption}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\begin{document}
\begin{table}[!ht]
\centering
\caption{RFA-Analyseergebnisse des ausgefilterten Feststoff (Partikelretention 8-15µm)}
\label{RFA_Filterkuchen_1}
\begin{tblr}{colspec = { *{9}{X[c]} },
row{1} = {font=\bfseries}
}
\toprule
A & Ni & Co & Mn & Cu & Fe & P & Ca & Si \\
\midrule
\qty{10.49}{\%} & \qty{22.68}{\%} & \qty{11.74}{\%} &
\qty{6.65}{\%} & \qty{1.29}{\%} & \qty{0.85}{\%} &
\qty{0.79}{\%} & \qty{0.36}{\%} & \qty{0.22}{\%} \\
\bottomrule
\end{tblr}
\end{table}
\end{document}