我在乳胶中绘制多列表格时遇到了问题。
有人可以帮忙吗?
文字和符号的颜色无关紧要。我想知道如何绘制这个表格。如果文字颜色也包括在内,我会很高兴。
这就是我目前正在尝试的。
\begin{document}
\begin{table}
\begin{tabular}{|l|l|l|l|l|l|l|l|l|l|l|l|}
\hline
\multirow{3}{*}{} &
\multicolumn{3}{c}{XSS} &
\multicolumn{1}{c}{CSRF} &
\multicolumn{4}{c}{SQLi} &
\multicolumn{2}{*}{POST} & GET \\
\multicolumn{3}{c}{BufferOverflow}\\
& StorePayloads & Sanitize(Invalid) & Successful & Anti-CSRF token & NOT & StorePAyloads & NOT & ReturnData & StorePayloads & InvalidToStore & Successful\\
\hline
Camera2 & & & & & & & & & & & & \\
\hline
Camera1 & & & & & & & & & & & & \\
\hline
Cam & & & & & & & & & & & & \\
\hline
IoT & & & & & & & & & & & & \\
\hline
\end{tabular}
\end{table}
\end{document}
答案1
我建议采用这种变体布局,其中只有表格主体有垂直线:
\documentclass{article}
\usepackage{pdflscape}
\usepackage{multirow}
\usepackage{makecell}
\usepackage[table, svgnames]{xcolor}
\usepackage{pifont}
\usepackage{bbding}
\def\cmb{\CheckmarkBold}
\renewcommand\theadfont{\normalsize}
\usepackage{booktabs}
\begin{document}
\begin{landscape}
\begin{table}
\setlength{\tabcolsep}{4.5pt}
\setcellgapes{4pt}\makegapedcells
\begin{tabular}{!{\vline width 0.8pt}l!{\vline width 0.8pt}*{2}{ >{\color{LimeGreen}}c|}>{\color{red}}c!{\vline width 0.8pt} *{3}{>{\color{red}}c!{\vline width 0.8pt}c|}c|>{\color{red}}c!{\vline width 0.8pt}}
\multicolumn{5}{c}{} & \multicolumn{4}{c}{\thead{SQLi}} \\[-0.5ex]
\cmidrule(lr){6-9}\addlinespace[-0.5ex]
\multicolumn{1}{c}{} & \multicolumn{3}{c}{XSS} & \multicolumn{1}{c}{CSRF} & \multicolumn{2}{c}{\thead{POST}} & \multicolumn{2}{c}{\thead{GET}} &
\multicolumn{3}{c}{BufferOverflow} \\[-1.5ex]
\cmidrule(r){2-4} \cmidrule(lr){5-5} \cmidrule(lr){6-7} \cmidrule(lr){8-9} \cmidrule(l){10-12}\addlinespace[-1.5ex]
\multicolumn{1}{c}{} & \multicolumn{1}{c}{\thead{Store\\ Payloads}} &\multicolumn{1}{c}{ \thead{Sanitize\\ (Invalid)}} & \multicolumn{1}{c}{\color{red}Successful} & \multicolumn{1}{>{\color{red}}c}{\thead{Anti-CSRF\\ token}} & \multicolumn{1}{c}{\thead{NOT}} & \multicolumn{1}{>{\color{red}}c}{\thead{Store\\ Payloads}} & \multicolumn{1}{c}{\thead{NOT}} & \multicolumn{1}{>{\color{red}}c}{\thead{Return\\ Data}} & \multicolumn{1}{c}{ \thead{Store\\ Payloads}} &\multicolumn{1}{c}{ \thead{Invalid\\ to store}} & \multicolumn{1}{>{\color{red}}c}{\thead{Successful}}\\[-0.5ex]
\Xhline{0.8pt}
Camera2 & \cmb & \cmb & & \ding{55} & & \cmb & & & & & \\
\hline
Camera1 &\cmb & \cmb & \cmb & \ding{55} & & \cmb & & & & &\cmb \\
\hline
Cam & \cmb & \cmb & \cmb & \ding{55} & & \cmb & & & & & \cmb \\
\hline
IoT & \cmb & & \cmb & \ding{55} & & & & \cmb & & & \cmb \\
\Xhline{0.8pt}
\end{tabular}
\end{table}
\end{landscape}
\end{document}
答案2
以下是表格的两个不同版本:
\documentclass{article}
\usepackage{pdflscape}
\usepackage{multirow}
\usepackage{makecell}
\renewcommand\theadfont{}
\usepackage{booktabs}
\begin{document}
\begin{landscape}
\begin{table}
\begin{tabular}{|l|l|l|l|l|l|l|l|l|l|l|l|}
\hline
&
\multicolumn{3}{c|}{\thead{XSS}} &
\multicolumn{1}{c|}{\thead{CSRF}} &
\multicolumn{4}{c|}{\thead{SQLi}} &
\multicolumn{3}{c|}{\thead{BufferOverflow}}\\ \cline{6-9}
& \multicolumn{3}{c|}{ } &
\multicolumn{1}{c|}{ } & \multicolumn{2}{c|}{\thead{POST}} & \multicolumn{2}{c|}{\thead{GET}} &\multicolumn{3}{c|}{ }\\ \hline
& \thead{Store\\ Payloads} & \thead{Sanitize\\ (Invalid)} & \thead{Successful} & \thead{Anti-CSRF\\ token} & \thead{NOT} & \thead{Store\\ Payloads} & \thead{NOT} & \thead{Return\\ Data} & \thead{Store\\ Payloads} & \thead{Invalid\\ to store} & \thead{Successful}\\
\hline
Camera2 & & & & & & & & & & & \\
\hline
Camera1 & & & & & & & & & & & \\
\hline
Cam & & & & & & & & & & & \\
\hline
IoT & & & & & & & & & & & \\
\hline
\end{tabular}
\end{table}
\begin{table}
\begin{tabular}{*{12}{l}}
&
\multicolumn{3}{c}{\thead{XSS}} &
\multicolumn{1}{c}{\thead{CSRF}} &
\multicolumn{4}{c}{\thead{SQLi}} &
\multicolumn{3}{c}{\thead{BufferOverflow}}\\ \cline{6-9}
& & & & & \multicolumn{2}{c}{\thead{POST}} & \multicolumn{2}{c}{\thead{GET}} & \\
\cmidrule(r){2-4} \cmidrule(lr){5-5} \cmidrule(lr){6-7} \cmidrule(lr){8-9} \cmidrule(l){10-12}
& \thead{Store\\ Payloads} & \thead{Sanitize\\ (Invalid)} & \thead{Successful} & \thead{Anti-CSRF\\ token} & \thead{NOT} & \thead{Store\\ Payloads} & \thead{NOT} & \thead{Return\\ Data} & \thead{Store\\ Payloads} & \thead{Invalid\\ to store} & \thead{Successful}\\
\midrule
Camera2 & & & & & & & & & & & \\
Camera1 & & & & & & & & & & & \\
Cam & & & & & & & & & & & \\
IoT & & & & & & & & & & & \\
\bottomrule
\end{tabular}
\end{table}
\end{landscape}
\end{document}
答案3
@leandriis 的答案到目前为止更为巧妙,但由于我已经这样做了,这里是我的简单尝试。我建议表格生成器来解决这样的事情。
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{table}[]
\begin{tabular}{|l|c|c|c|c|c|c|c|c|c|c|c|}
\hline
& \multicolumn{3}{c|}{\multirow{2}{*}{xs}} & \multirow{2}{*}{cs} & \multicolumn{4}{c|}{sq} & \multicolumn{3}{c|}{\multirow{2}{*}{bo}} \\ \cline{6-9}
& \multicolumn{3}{c|}{} & & \multicolumn{2}{c|}{po} & \multicolumn{2}{c|}{ge} & \multicolumn{3}{c|}{} \\ \cline{2-12}
& SP & SI & SU & ant & not & store & nt & rtn & stp & inv & suc \\ \hline
Camera & & & & & & & & & & & \\ \hline
Camera & & & & & & & & & & & \\ \hline
Cam & & & & & & & & & & & \\ \hline
IoT & & & & & & & & & & & \\ \hline
\end{tabular}
\end{table}
\end{document}
答案4
这是我得到的:
\documentclass[
10pt,%
a4paper,%
oneside,%
]{article}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[left=1cm, right=1cm]{geometry}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{xcolor}
\usepackage{comment}
\newcolumntype{R}{>{\hspace{0pt}}p{1cm}}
\begin{document}
\begin{table}[t]
\centering
\caption{My table.}
\begin{tabular}[t]{|p{2cm}|R|R|R|R|R|R|R|R|R|R|R|}
\hline
\multirow{3}{*}{} & \multicolumn{3}{c|}{\multirow[t]{3}{*}{XSS}} & \multirow[t]{2}{*}{CSRF} & \multicolumn{4}{c|}{SQL injection} & \multicolumn{3}{c|}{\multirow[t]{2}{*}{Buffer Overflow}}\\
\cline{6-9}
& \multicolumn{3}{c|}{} & & \multicolumn{2}{c|}{POST} & \multicolumn{2}{c|}{GET} & \multicolumn{3}{c|}{} \\
\cline{2-12}
& Store Payloads & Sanitize (invalid) & \textcolor{red}{Successful} & \textcolor{red}{Anti-CSRf token} & NOT & \textcolor{red}{Store Payloads} & NOT & \textcolor{red}{Return Data} & Store Payloads & Invalid to store & \textcolor{red}{Successful}\\
\hline
Camera2 & & & & & & & & & & & \\
\hline
Camera1 & & & & & & & & & & & \\
\hline
Cam & & & & & & & & & & & \\
\hline
IoT & & & & & & & & & & & \\
\hline
\end{tabular}
\end{table}
\end{document}