我只有一张小桌子,想使用浮动包,在框旁边书写。我现在遇到的问题是,表格的标题,甚至表格编号,并没有移动到左侧,而是仍然在中间。
这是我的代码:
\begin{table}[ht!]
\caption{|l|}{Performance Overview (in \%)}
\label{tab:Performance Overview - in percent}
\begin{floatingtable}[l]{
\begin{tabular}{|l|l|l|}
\hline
\rowcolor[HTML]{000000}
{\color[HTML]{FFFFFF} \textbf{n}} & {\color[HTML]{FFFFFF} \textbf{Test (A)}} & {\color[HTML]{FFFFFF} \textbf{Test (B)}} \\ \hline
\textit{1} & {\color[HTML]{000000} 99,38\%} & {\color[HTML]{000000} 98,55\%} \\ \hline
\textit{2} & {\color[HTML]{000000} 99,03\%} & {\color[HTML]{000000} 98,73\%} \\ \hline
\textit{3} & {\color[HTML]{000000} \textbf{93,80\%}} & {\color[HTML]{000000} 98,86\%} \\ \hline
\textit{4} & {\color[HTML]{000000} 98,76\%} & {\color[HTML]{000000} 99,00\%} \\ \hline
\textit{5} & {\color[HTML]{000000} 99,31\%} & {\color[HTML]{000000} 99,15\%} \\ \hline
\textit{6} & {\color[HTML]{000000} 98,49\%} & {\color[HTML]{000000} 98,01\%} \\ \hline
\textit{7} & {\color[HTML]{000000} 98,34\%} & {\color[HTML]{000000} 99,00\%} \\ \hline
\textbf{Total} & {\color[HTML]{000000} \textbf{98,16\%}} & {\color[HTML]{000000} \textbf{98,76\%}} \\ \hline
\end{tabular}}
\end{floatingtable}
\end{table}
到目前为止,我找到的解决方案都没有展示如何设置表格名称(表 5.8)。但如果所有内容都放在左侧,只有标题居中,那么显然看起来有点陈旧。
我将非常感谢一个解决方案,其中整个表格包括标题,表格编号等都在左侧网站上。
提前感谢
答案1
- 你的问题不清楚,抱歉
- 您没有提供 MWE(最小工作示例,一个完整的、可编译的小文档,可以演示您的问题)
- 您的表格中充斥着杂乱无章的内容,每个单元格中的文字都带有颜色(黑色),如果有多余的文字等等(请参阅下面的 MWE)
猜测你的问题是什么,我想出了两个可能的解决方案:
\documentclass{article}
\usepackage[skip=1ex]{caption}
\usepackage[table]{xcolor}
\newcommand\mcw[1]{\multicolumn{1}{c}{\textcolor{white}{\textbf{#1}}}}
\usepackage{array}
\usepackage{siunitx}
\usepackage{etoolbox}
\renewcommand{\bfseries}{\fontseries{b}\selectfont}
\newrobustcmd{\B}{\bfseries}
\usepackage[leftcaption]{sidecap}
\usepackage{lipsum}
\begin{document}
\lipsum[66]
\begin{table}[ht]
\captionsetup{singlelinecheck=false,font=small,labelfont=bf}
\sisetup{detect-weight,
mode=text,
table-format=2.2,
table-space-text-post={\,\%}
}
\renewcommand\arraystretch{1.1}
\caption{Performance Overview}
\label{tab:Performance Overview - in percent}
\begin{tabular}{>{\itshape}c *{2}{S<{\,\%}} }
\hline
\rowcolor{black}
\mcw{n}
& \mcw{Test (A)}
& \mcw{Test (B)} \\
\hline
1 & 99,38 & 98,55 \cr
2 & 99,03 & 98,73 \cr
3 &\B 93,80 & 98,86 \cr
4 & 98,76 & 99,00 \cr
5 & 99,31 & 99,15 \cr
6 & 98,49 & 98,01 \cr
7 & 98,34 & 99,00 \cr
\hline
\textbf{Total}
&\B 98,16 &\B 98,76 \cr
\hline
\end{tabular}
\end{table}
\lipsum[66]
\begin{SCtable}[][ht]
\captionsetup{singlelinecheck=false,font=small,labelfont=bf}
\sisetup{detect-weight,
mode=text,
table-format=2.2,
table-space-text-post={\,\%}
}
\renewcommand\arraystretch{1.1}
\caption{Performance Overview}
\label{tab:Performance Overview - in percent}
\begin{tabular}{>{\itshape}c *{2}{S<{\,\%}} }
\hline
\rowcolor{black}
\mcw{n}
& \mcw{Test (A)}
& \mcw{Test (B)} \\
\hline
1 & 99,38 & 98,55 \cr
2 & 99,03 & 98,73 \cr
3 &\B 93,80 & 98,86 \cr
4 & 98,76 & 99,00 \cr
5 & 99,31 & 99,15 \cr
6 & 98,49 & 98,01 \cr
7 & 98,34 & 99,00 \cr
\hline
\textbf{Total}
&\B 98,16 &\B 98,76 \cr
\hline
\end{tabular}
\end{SCtable}
\end{document}
附录:
您似乎正在寻找wraptable
由“wrapfig 包”提供的环境:
\documentclass{article}
\usepackage[singlelinecheck=false,
font=small,
labelfont=bf,
skip=1ex]{caption}
\usepackage[table]{xcolor}
\newcommand\mcw[1]{\multicolumn{1}{c}{\textcolor{white}{\textbf{#1}}}}
\usepackage{array}
\usepackage{siunitx}
\usepackage{etoolbox}
\renewcommand{\bfseries}{\fontseries{b}\selectfont}
\newrobustcmd{\B}{\bfseries}
\usepackage{wrapfig}
\usepackage{lipsum}
\begin{document}
%\lipsum[66]
\begin{wraptable}[12]{R}{0.4\textwidth}
%\vspace*{-\baselineskip}
\sisetup{detect-weight,
mode=text,
table-format=2.2,
table-space-text-post={\,\%}
}
\renewcommand\arraystretch{1.1}
\caption{Performance Overview}
\label{tab:Performance Overview - in percent}
\begin{tabular}{>{\itshape}c *{2}{S<{\,\%}} }
\hline
\rowcolor{black}
\mcw{n}
& \mcw{Test (A)}
& \mcw{Test (B)} \\
\hline
1 & 99,38 & 98,55 \cr
2 & 99,03 & 98,73 \cr
3 &\B 93,80 & 98,86 \cr
4 & 98,76 & 99,00 \cr
5 & 99,31 & 99,15 \cr
6 & 98,49 & 98,01 \cr
7 & 98,34 & 99,00 \cr
\hline
\textbf{Total}
&\B 98,16 &\B 98,76 \cr
\hline
\end{tabular}
\end{wraptable}
\lipsum[1-2]
\end{document}
答案2
编辑我之前的回答——我的某些错误已被删除
请看看是否合适
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage[labelfont=bf]{caption}
\begin{document}
\begin{table}[ht!]
\centering
\captionsetup[table]{labelsep=space, justification=raggedright, singlelinecheck=off}
\caption{Performance Overview(in \%)\hfill\mbox{}}
\label{tab:Performance Overview - in percent}
\begin{tabular}{lll} \hline
\rowcolor[HTML]{000000}{\color[HTML]{FFFFFF} \textbf{n}} & {\color[HTML]{FFFFFF} \textbf{Test (A)}} & {\color[HTML]{FFFFFF} \textbf{Test (B)}} \\ \hline
\textit{1} & {\color[HTML]{000000} 99,38} & {\color[HTML]{000000} 98,55} \\ \hline
\textit{2} & {\color[HTML]{000000} 99,03} & {\color[HTML]{000000} 98,73} \\ \hline
\textit{3} & {\color[HTML]{000000} \textbf{93,80}} & {\color[HTML]{000000} 98,86} \\ \hline
\textit{4} & {\color[HTML]{000000} 98,76} & {\color[HTML]{000000} 99,00} \\ \hline
\textit{5} & {\color[HTML]{000000} 99,31} & {\color[HTML]{000000} 99,15} \\ \hline
\textit{6} & {\color[HTML]{000000} 98,49} & {\color[HTML]{000000} 98,01} \\ \hline
\textit{7} & {\color[HTML]{000000} 98,34} & {\color[HTML]{000000} 99,00} \\ \hline
\textbf{Total} & {\color[HTML]{000000} \textbf{98,16}} & {\color[HTML]{000000} \textbf{98,76}} \\ \hline
\end{tabular}
\end{table}
\end{document}