![文章中的表格边距](https://linux22.com/image/452457/%E6%96%87%E7%AB%A0%E4%B8%AD%E7%9A%84%E8%A1%A8%E6%A0%BC%E8%BE%B9%E8%B7%9D%20.png)
我有下表:
我有以下问题:
- 有什么方法可以强制表格与文章文本的宽度相同?
- 并且强制所有列具有相同的大小?
- 另外,强制表格只出现在一页上,而不与页码重叠?
代码:
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcommand{\tilt}[2][14em]{\rotatebox[origin=r]{90}{\parbox{#1}{\raggedleft #2}}}
\noindent\begin{table}
\FloatBarrier
\renewcommand{\arraystretch}{1.2}%
\begin{tabularx}{\textwidth}{ |P{12em}| |C|C|C| |C|C|C|C|C|C|C|C|C|C| }
\hline
\textbf{Paper(s)} &
\multicolumn{3}{|c||}{\textbf{Data Sources}} &
\multicolumn{9}{|c||}{\textbf{Technique}} \\
\cline{2-13}
&
\tilt{\textbf{Log-based}} &
\tilt{\textbf{Distributed Tracing-based}} &
\tilt{\textbf{Monitoring-Based}} &
\tilt{\textbf{Unsupervised learning}} &
\tilt{\textbf{Supervised learning}} &
\tilt{\textbf{Reinforcement learning}} &
\tilt{\textbf{Semi-supervised learning}} &
\tilt{\textbf{Statistical Approach}} &
\tilt{\textbf{Causal Inference}} &
\tilt{\textbf{Trace comparison}} &
\tilt{\textbf{HeartBeating}} &
\tilt{\textbf{SLO checks}} \\
\hline
\cite{liu2020unsupervised, nedelkoski2019anomaly, vallis2014novel, pahl2018all, jin2020anomaly, bogatinovski2020self} &
& % Log-based
\textbullet & % Distributed Tracing-based
& % Monitoring-Based
\textbullet & % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\hline
\cite{gan2019leveraging, zhou2019latent} &
& % Log-based
\textbullet & % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
\textbullet & % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\hline
\cite{wang2020workflow, chen2020framework, meng2021detecting} &
& % Log-based
\textbullet & % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
\textbullet & % Trace comparison
& % HeartBeating
% SLO checks
\\
\hline
\end{tabularx}
\FloatBarrier
\end{table}
更新
我按照@Zarko 的建议编辑了表格。是否可以降低文章行高?我觉得高度太大,导致表格超出了页面边缘。
代码:
\documentclass{article}
\usepackage{geometry}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum} % for dummy text
%---------------------------------------------------------------%
\usepackage{rotating}
\usepackage{makecell}
\usepackage{tabularray}
\begin{document}
\begin{table}[ht]
\settowidth\rotheadsize{\small Monitoring-Based} % from makecell
\begin{tblr}{hlines, vlines,
colspec = {Q[l, wd=11em] | *{3}{X[c]} | *{9}{X[c]}},
colsep = 3pt,
row{1} = {font=\small\bfseries\linespread{0,84}\selectfont, c, m},
row{2} = {cmd=\rotcell, font=\small\linespread{0,84}\selectfont, rowsep=0pt}
}
Paper(s)
& \SetCell[c=3]{c, m} {Data\\ Sources}
& & & \SetCell[c=9]{c, m} Technique
& & & & & & & & \\
& Log-based
& Distributed Tracing-based
& Monitoring-Based
& {Unsupervised\\ learning}
& Supervised learning
& Reinforcement learning
& Semi-supervised learning
& Statistical Approach
& Causal Inference
& Trace comparison
& Heart Beating
& SLO checks \\
\cite{liu2020unsupervised, nedelkoski2019anomaly, vallis2014novel, pahl2018all, jin2020anomaly, bogatinovski2020self} &
& % Log-based
\textbullet & % Distributed Tracing-based
& % Monitoring-Based
\textbullet & % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{gan2019leveraging, zhou2019latent} &
& % Log-based
\textbullet & % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
\textbullet & % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{wang2020workflow, chen2020framework, meng2021detecting} &
& % Log-based
\textbullet & % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
\textbullet & % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{li2021microservice} &
& % Log-based
\textbullet & % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
\textbullet & % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{chow2014mystery} &
& % Log-based
\textbullet & % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
\textbullet & % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{belhadi2021reinforcement} &
& % Log-based
\textbullet & % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
\textbullet & % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{sharma2013cloudpd, zhang2016taskinsight, xu2018unsupervised, gulenko2018detecting, mariani2018localizing, wu2020microrca, wu2020performance, wang2018cloudranger} &
& % Log-based
& % Distributed Tracing-based
\textbullet & % Monitoring-Based
\textbullet & % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{sauvanaud2018anomaly, liu2015opprentice, du2018anomaly, mariani2020predicting, samir2019dla} &
& % Log-based
& % Distributed Tracing-based
\textbullet & % Monitoring-Based
& % Unsupervised learning
\textbullet & % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{magalhaes2010detection, peiris2014pad, abdelrahman2016detection, kang2012dapa, yang2007anomaly, wang2013energy, ahad2015toward, nguyen2013fchain, tan2012prepare, gu2009online} &
& % Log-based
& % Distributed Tracing-based
\textbullet & % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
\textbullet & % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{chen2014causeinfer, chen2016causeinfer, shan2019diagnosis, lin2018microscope} &
& % Log-based
& % Distributed Tracing-based
\textbullet & % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
\textbullet % SLO checks
\\
\cite{zang2018fault} &
& % Log-based
& % Distributed Tracing-based
\textbullet & % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
\textbullet & % HeartBeating
% SLO checks
\\
\cite{du2017deeplog, yagoub2018equipment, liang2007failure, zhang2016automated, brown2018recurrent, meng2019loganomaly, zhang2019robust, nandi2016anomaly, jia2017logsed, fu2009execution} &
\textbullet & % Log-based
& % Distributed Tracing-based
& % Monitoring-Based
\textbullet & % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{fronza2013failure} &
\textbullet & % Log-based
& % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
\textbullet & % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{fu2009execution} &
\textbullet & % Log-based
& % Distributed Tracing-based
& % Monitoring-Based
\textbullet & % Unsupervised learning
\textbullet & % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{yang2021semi} &
\textbullet & % Log-based
& % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
\textbullet & % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{salfner2007using, beschastnikh2014inferring} &
\textbullet & % Log-based
& % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
\textbullet & % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\end{tblr}
\end{table}
\end{document}
谢谢
答案1
使用tabularray
、rotating
和makecell
包后,旋转的文本在必要时会分为两行。
编辑: 表格代码已扩展,其中包含编辑问题中提供的行。添加行后,表格仍可放在一页上。
\documentclass{article}
\usepackage{geometry}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum} % for dummy text
%---------------------------------------------------------------%
\usepackage{rotating}
\usepackage{makecell}
\usepackage{tabularray}
\begin{document}
\begin{table}[ht]
\settowidth\rotheadsize{\small Monitoring-Based} % from makecell
\begin{tblr}{hlines, vlines,
colspec = {Q[l, m, wd=11em] | *{3}{X[c]} | *{9}{X[c]}},
colsep = 3pt,
row{1} = {font=\small\bfseries\linespread{0,84}\selectfont, c, m},
row{2} = {cmd=\rotcell, font=\small\linespread{0,84}\selectfont, rowsep=0pt}
}
Paper(s)
& \SetCell[c=3]{c, m} {Data\\ Sources}
& & & \SetCell[c=9]{c, m} Technique
& & & & & & & & \\
& Log-based
& Distributed Tracing-based
& Monitoring-Based
& {Unsupervised\\ learning}
& Supervised learning
& Reinforcement learning
& Semi-supervised learning
& Statistical Approach
& Causal Inference
& Trace comparison
& Heart Beating
& SLO checks \\
\cite{liu2020unsupervised, nedelkoski2019anomaly, vallis2014novel, pahl2018all, jin2020anomaly, bogatinovski2020self}
& \textbullet
& & & \textbullet
& & & & & & & & \\
\cite{gan2019leveraging, zhou2019latent}
& & \textbullet
& & \textbullet
& & & & & & & & \\
\cite{wang2020workflow, chen2020framework, meng2021detecting}
& & \textbullet
& & & & & & & & \textbullet
& & \\
% data from added rows in question
\cite{li2021microservice} &
& \textbullet
& & & & & \textbullet
& & & & & & \\
\cite{chow2014mystery}
& & \textbullet
& & & & & & & \textbullet
& & & \\
\cite{belhadi2021reinforcement}
& & \textbullet
& & & & \textbullet
& & & & & & \\
\cite{sharma2013cloudpd, zhang2016taskinsight, xu2018unsupervised, gulenko2018detecting, mariani2018localizing, wu2020microrca, wu2020performance, wang2018cloudranger}
& & & \textbullet
& \textbullet
& & & & & & & & \\
\cite{sauvanaud2018anomaly, liu2015opprentice, du2018anomaly, mariani2020predicting, samir2019dla}
& & & \textbullet
& & \textbullet
& & & & & & & \\
\cite{magalhaes2010detection, peiris2014pad, abdelrahman2016detection, kang2012dapa, yang2007anomaly, wang2013energy, ahad2015toward, nguyen2013fchain, tan2012prepare, gu2009online}
& & & \textbullet
& & & & & \textbullet
& & & & \\
\cite{chen2014causeinfer, chen2016causeinfer, shan2019diagnosis, lin2018microscope}
& & & \textbullet
& & & & & & & & & \textbullet \\
\cite{zang2018fault}
& & & \textbullet
& & & & & & & & \textbullet
& \\
\cite{du2017deeplog, yagoub2018equipment, liang2007failure, zhang2016automated, brown2018recurrent, meng2019loganomaly, zhang2019robust, nandi2016anomaly, jia2017logsed, fu2009execution}
& \textbullet
& & & \textbullet
& & & & & & & & \\
\cite{fronza2013failure}
& \textbullet
& & & & \textbullet
& & & & & & & \\
\cite{fu2009execution}
& \textbullet
& & & \textbullet
& \textbullet
& & & & & & & \\
\cite{yang2021semi}
& \textbullet
& & & & & & \textbullet
& & & & & \\
\cite{salfner2007using, beschastnikh2014inferring}
& \textbullet
& & & & & & & \textbullet
& & & & \\
\end{tblr}
\end{table}
\end{document}
Paper(s)
& \SetCell[c=3]{c, m} {Data\\ Sources}
& & & \SetCell[c=9]{c, m} Technique
& & & & & & & & & \\
\end{tblr}
\end{table}
\end{document}
(红线表示页面布局)
笔记:
- 除第一列外,所有列的宽度均相等。
- 表格宽度等于
\textwidth
。 - 表格可以轻松放入一页,甚至在编辑的问题中添加宽度行
- 我们没有关于您的文档页面布局的任何信息,因此不知道有多少空间可用于表格。现在在编辑的问题中被视为 MWE(显然是基于此答案)。
- 请在您最终的新问题中始终提供 MWE ) 最小工作示例 =,一份完整的小文档,其中显示了您的问题
答案2
除了 Zarko 的回答之外,您还可以选择减少数字行以及使用自定义规则booktabs
。桌子很大。一个建议是在横向环境中排版表格。另一种方法是添加交替颜色并删除多条水平线,如果您想增加每行的高度,这可能更可取。
\documentclass{article}
% \usepackage{geometry} % for changing a document layout
\usepackage{pdflscape}
\usepackage{rotating}
\usepackage{makecell}
\usepackage{xcolor}
\colorlet{bgodd}{black!10}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\usepackage{lipsum} % for dummy text
\begin{document}
\lipsum[1]
\begin{landscape}
\begin{table}[ht]
% from makecell
\settowidth\rotheadsize{\small Monitoring-Based}
\begin{tblr}{
colspec = {Q[l, wd=5cm] *{3}{X[c]} *{9}{X[c]}},
vline{2-Y} = {2-Z}{dotted},
vline{2,5} = {2-Z}{solid, \lightrulewidth}, % \lightrulewidth is defined in booktabs
rows = {abovesep=2pt, belowsep=2pt},
row{odd} = {bg=bgodd},
colsep = 2pt,
row{1} = {
font=\bfseries, %\linespread{0.84}\selectfont,
c, m,
},
row{2} = {
cmd=\rotcell,
rowsep=0pt
},
}
\toprule
\SetRow{bg=white}
Paper(s) &
\SetCell[c=3]{c, m} {Data\\ Sources} &&&
\SetCell[c=9]{c, m} Technique &&&&&&&& \\
\midrule
& Log-based
& Distributed Tracing-based
& Monitoring-Based
& {Unsupervised\\ learning}
& Supervised learning
& Reinforcement learning
& Semi-supervised learning
& Statistical Approach
& Causal Inference
& Trace comparison
& Heart Beating
& SLO checks \\
\midrule
\cite{liu2020unsupervised, nedelkoski2019anomaly, vallis2014novel, pahl2018all, jin2020anomaly, bogatinovski2020self} &
& % Log-based
\textbullet & % Distributed Tracing-based
& % Monitoring-Based
\textbullet & % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{gan2019leveraging, zhou2019latent} &
& % Log-based
\textbullet & % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
\textbullet & % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{wang2020workflow, chen2020framework, meng2021detecting} &
& % Log-based
\textbullet & % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
\textbullet & % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{li2021microservice} &
& % Log-based
\textbullet & % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
\textbullet & % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{chow2014mystery} &
& % Log-based
\textbullet & % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
\textbullet & % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{belhadi2021reinforcement} &
& % Log-based
\textbullet & % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
\textbullet & % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{sharma2013cloudpd, zhang2016taskinsight, xu2018unsupervised, gulenko2018detecting, mariani2018localizing, wu2020microrca, wu2020performance, wang2018cloudranger} &
& % Log-based
& % Distributed Tracing-based
\textbullet & % Monitoring-Based
\textbullet & % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{sauvanaud2018anomaly, liu2015opprentice, du2018anomaly, mariani2020predicting, samir2019dla} &
& % Log-based
& % Distributed Tracing-based
\textbullet & % Monitoring-Based
& % Unsupervised learning
\textbullet & % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{magalhaes2010detection, peiris2014pad, abdelrahman2016detection, kang2012dapa, yang2007anomaly, wang2013energy, ahad2015toward, nguyen2013fchain, tan2012prepare, gu2009online} &
& % Log-based
& % Distributed Tracing-based
\textbullet & % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
\textbullet & % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{chen2014causeinfer, chen2016causeinfer, shan2019diagnosis, lin2018microscope} &
& % Log-based
& % Distributed Tracing-based
\textbullet & % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
\textbullet % SLO checks
\\
\cite{zang2018fault} &
& % Log-based
& % Distributed Tracing-based
\textbullet & % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
\textbullet & % HeartBeating
% SLO checks
\\
\cite{du2017deeplog, yagoub2018equipment, liang2007failure, zhang2016automated, brown2018recurrent, meng2019loganomaly, zhang2019robust, nandi2016anomaly, jia2017logsed, fu2009execution} &
\textbullet & % Log-based
& % Distributed Tracing-based
& % Monitoring-Based
\textbullet & % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{fronza2013failure} &
\textbullet & % Log-based
& % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
\textbullet & % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{fu2009execution} &
\textbullet & % Log-based
& % Distributed Tracing-based
& % Monitoring-Based
\textbullet & % Unsupervised learning
\textbullet & % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{yang2021semi} &
\textbullet & % Log-based
& % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
\textbullet & % Semi-supervised learning
& % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\cite{salfner2007using, beschastnikh2014inferring} &
\textbullet & % Log-based
& % Distributed Tracing-based
& % Monitoring-Based
& % Unsupervised learning
& % Supervised learning
& % Reinforcement learning
& % Semi-supervised learning
\textbullet & % Statistical Approach
& % Causal Inference
& % Trace comparison
& % HeartBeating
% SLO checks
\\
\midrule
\end{tblr}
\end{table}
\end{landscape}
\lipsum[2]
\end{document}