![LaTeX 表未定义控制序列](https://linux22.com/image/375218/LaTeX%20%E8%A1%A8%E6%9C%AA%E5%AE%9A%E4%B9%89%E6%8E%A7%E5%88%B6%E5%BA%8F%E5%88%97.png)
我知道这是与表相关的错误的一个非常常见的现象,所以提前感谢您的任何帮助(我已经很累了:-)
)。
我有一张表,由于某种原因,它拒绝编译。我认为它以前就是这样的,我看不出错误的变化发生在哪里。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage[acronym]{glossaries}
\begin{document}
\newacronym{mno}{MNO}{Mobile Network Operator}
\newacronym{sdn}{SDN}{Software Defined Networking}
\newacronym{nfv}{NFV}{Network Function Virtualization}
\newacronym{vnf}{VNF}{Virtualized Network Function}
\newacronym{nve}{NVE}{Network Virtualization Environment}
\begin{table*}[t]
\centering
\caption{\gls{sdn} and \gls{nfv} multitenant environment fault management issues and consequences}
\label{TAB-issues}
\resizebox{\textwidth}{!}{
\begin{tabular}{c|l|l|l|l|l|}
\cline{2-6}
\multicolumn{1}{l|}{} & \multicolumn{1}{c|}{\textbf{ISSUES}} & \textbf{\gls{sdn}?} & \multicolumn{1}{c|}{\textbf{\gls{nfv}?}} & \textbf{\begin{tabular}[c]{@{}l@{}}Multi-\\ tenant?\end{tabular}} & \multicolumn{1}{c|}{\textbf{CONSEQUENCES}} \\ \hline
\multicolumn{1}{|c|}{\multirow{3}{*}{\textbf{Scalability}}} & 1) Huge requests to the \gls{sdn} controller & \checkmark & & Limited \gls{sdn} controller capacity \\ \cline{2-6}
\multicolumn{1}{|c|}{} & 2) Huge number of faults and alarms & \checkmark & \checkmark & \checkmark & Alarms correlation and fault detection \\ \cline{2-6}
\multicolumn{1}{|c|}{} & 3) A growing number of tenants and resources affectation & & & \checkmark & Optimization of resources allocation \\ \hline
\multicolumn{1}{|c|}{\multirow{3}{*}{\textbf{Topology}}} & 4) Dynamic topology & & & & Difficulty of modeling the network topology \\ \cline{2-6}
\multicolumn{1}{|c|}{} & 5) Coexistence of Physical and virtual entities & \checkmark & \checkmark & \checkmark & Virtual and physical faults dependencies \\ \cline{2-6}
\multicolumn{1}{|c|}{} & 6) Multi-tenants & & & \checkmark & Lack of network visibility \\ \hline
\multicolumn{1}{|c|}{\multirow{2}{*}{\textbf{Security}}} & 7) Attack on switches or controllers or control plane & \checkmark & & & Whole network disruption \\ \cline{2-6}
\multicolumn{1}{|c|}{} & 8) Multi-tenant sharing the same infrastructure & & & \checkmark & Multi-tenants traffic isolation \\ \hline
\multicolumn{1}{|c|}{\multirow{5}{*}{\textbf{Fault Tolerance}}} & 9) A single \gls{sdn} controller a single point of failure & \checkmark & & & \gls{sdn} controller failure implies the,whole network failure \\ \cline{2-6}
\multicolumn{1}{|c|}{} & 10) Link failure & \checkmark & \checkmark & & Loss of network connection \\ \cline{2-6}
\multicolumn{1}{|c|}{} & 11) End to End service chain crash & & \checkmark & & Rapid detection and recovery actions for clients services \\ \cline{2-6}
\multicolumn{1}{|c|}{} & 12) Physical and virtual faults & \checkmark & \checkmark & & A physical failure may impact multiple virtual entities \\ \cline{2-6}
\multicolumn{1}{|c|}{} & 13) Multi-tenants faults & & & \checkmark & The necessity of tenants faults isolation and notification \\ \hline
\multicolumn{1}{|c|}{\multirow{3}{*}{\textbf{Performance}}} & 14) \gls{sdn} controller and switch performance &\checkmark & & & Choose the best network configurations to have a high network resilience \\ \cline{2-6}
\multicolumn{1}{|c|}{} & 15) Running environments & &\checkmark & & The performance of the \gls{vnf} depends on the running environment \\ \cline{2-6}
\multicolumn{1}{|c|}{} & 16) Migration of tenants applications or \gls{vnf} & & \checkmark & \checkmark & Keep the same performance while migrating a tenant application or a \gls{vnf} \\ \hline
\end{tabular}
}
\end{table*}
\end{document}
如您所见,错误不是缺少包或首字母缩略词(至少我认为是这样),尝试使用 sharelatex 或 overleaf 会返回错误:
./main.tex:42: Undefined control sequence.
<argument> ... \gls {sdn} controller & \checkmark
& & Limited \gls {sdn} con...
l.42 }
这确实很难解决:-(
。
谢谢您对此的任何启发!
答案1
正如评论中提到的,您收到错误是因为命令\checkmark
未定义。通过加载定义\checkmark
命令的包(例如),amssymb
可以使您的代码可编译。
由于您的表格很宽,我建议不要使用,resizebox
因为它会导致字体大小小且不一致,难以辨认。在以下 MWE 中,我更改了表格的总体布局,使其适合一页。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage[acronym]{glossaries}
\usepackage{makecell}
\usepackage{rotating}
\usepackage{threeparttable}
\usepackage{booktabs}
\usepackage{ragged2e}
\usepackage{array}
\makeatletter
\def\@rothead[#1]#2{\thead{\\[-.65\normalbaselineskip]\turn{\cellrotangle}\thead[#1]{#2}\endturn}}
\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\newcolumntype{Z}{>{\RaggedRight\arraybackslash}X}
\begin{document}
\newacronym{mno}{MNO}{Mobile Network Operator}
\newacronym{sdn}{SDN}{Software Defined Networking}
\newacronym{nfv}{NFV}{Network Function Virtualization}
\newacronym{vnf}{VNF}{Virtualized Network Function}
\newacronym{nve}{NVE}{Network Virtualization Environment}
\begin{table}[t]
\centering
\caption{\gls{sdn} and \gls{nfv} multitenant environment fault management issues and consequences}
\label{TAB-issues}
\footnotesize
\renewcommand{\arraystretch}{1.25}
\begin{threeparttable}
\begin{tabularx}{\textwidth}{cr@{\hspace{1ex}}L{2.75cm}c@{\hspace{3pt}}c@{\hspace{3pt}}cZ}
\toprule
& \multicolumn{2}{l}{ISSUES} & \gls{sdn}? & \gls{nfv}? & \makecell{Multi-\\tenant?} & CONSEQUENCES \\
\midrule
\multirow{7}{*}{\rothead[c]{Scalability}} & 1)& Huge requests to the \gls{sdn} controller & \checkmark & & \tnote{*} \\
& 2) & Huge number of faults and alarms & \checkmark & \checkmark & \checkmark & Alarms correlation and fault detection \\
& 3) & A growing number of tenants and resources affectation & & & \checkmark & Optimization of resources allocation \\
\midrule
\multirow{6}{*}{\rothead[c]{Topology}} & 4)& Dynamic topology & & & & Difficulty of modeling the network topology \\
& 5) & Coexistence of Physical and virtual entities & \checkmark & \checkmark & \checkmark & Virtual and physical faults dependencies \\
& 6) & Multi-tenants & & & \checkmark & Lack of network visibility \\
\midrule
\multirow{6}{*}{\rothead[c]{Security}} & 7)& Attack on switches or controllers or control plane & \checkmark & & & Whole network disruption \\
& 8)& Multi-tenant sharing the same infrastructure & & & \checkmark & Multi-tenants traffic isolation \\ \hline
\multirow{10}{*}{\rothead[c]{Fault Tolerance}} & 9)& A single \gls{sdn} controller a single point of failure & \checkmark & & & \gls{sdn} controller failure implies the,whole network failure \\
& 10)& Link failure & \checkmark & \checkmark & & Loss of network connection \\
& 11) & End to End service chain crash & & \checkmark & & Rapid detection and recovery actions for clients services \\
& 12) & Physical and virtual faults & \checkmark & \checkmark & & A physical failure may impact multiple virtual entities \\
& 13) & Multi-tenants faults & & & \checkmark & The necessity of tenants faults isolation and notification \\
\midrule
\multirow{9}{*}{\rothead[c]{Performance}} & 14)& \gls{sdn} controller and switch performance &\checkmark & & & Choose the best network configurations to have a high network resilience \\
& 15) & Running environments & &\checkmark & & The performance of the \gls{vnf} depends on the running environment \\
& 16)& Migration of tenants applications or \gls{vnf} & & \checkmark & \checkmark & Keep the same performance while migrating a tenant application or a \gls{vnf} \\
\bottomrule
\end{tabularx}
\begin{tablenotes}
\item[*] Limited \gls{sdn} controller capacity
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
与您的原始代码相比,我做了以下更改:
- 删除列标题中的粗体。
- 从包中的规则中删除了所有垂直线并替换了水平线,
booktabs
并在其周围添加了适当的空白。 - 旋转第一列的内容(代码
\rothead
取自此处:https://tex.stackexchange.com/a/429133/134144) - 用于
threeparttable
将“多租户”列中的长文本放入表格注释中。 - 减少了包含列的复选标记之间的距离,以节省一些水平空间。
- 添加了包含数字的新第二列。这样,相应文本的第二行及后续行将自动缩进。
- 对“问题”列使用固定宽度且右对齐的列,以便实现自动换行。
X
从包中使用灵活宽度的列tabularx
,以使表格与文本宽度一样宽。- 将复选标记水平居中放置在其对应的列中。
- 在列的上方和下方添加了一些额外的垂直空白以引导读者的视线。
- ...
答案2
这里有一个解决方案,它 (a) 以横向格式呈现表格,并且 (b) 允许在两列中自动换行,从而避免使用\resizebox
。还请注意,我简化了第一列中的材料,主要是通过获取\multirow
“包装器”。(哦,一定要确保amssymb
包已加载,以访问\checkmark
宏。)
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry} % set page parameters suitably
\usepackage{amsmath,amssymb}
\usepackage{rotating,tabularx,ragged2e}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\usepackage[acronym]{glossaries}
\begin{document}
\newacronym{mno}{MNO}{Mobile Network Operator}
\newacronym{sdn}{SDN}{Software Defined Networking}
\newacronym{nfv}{NFV}{Network Function Virtualization}
\newacronym{vnf}{VNF}{Virtualized Network Function}
\newacronym{nve}{NVE}{Network Virtualization Environment}
\begin{sidewaystable}
\caption{\gls{sdn} and \gls{nfv} multitenant
environment fault management issues and consequences}
\label{TAB-issues}
\small % 10% linear reduction in font size
\setlength\extrarowheight{2pt}
\setlength\tabcolsep{4pt} % default: 6pt
\begin{tabularx}{\textwidth}{|>{\bfseries}l|L|c|c|>{\centering}p{1.5cm}|L|}
\cline{2-6}
\multicolumn{1}{c|}{} & \textbf{Issues}
& \textbf{\gls{sdn}?} & \textbf{\gls{nfv}?}
& \textbf{Multi-tenant?} & \textbf{Consequences}
\\ \hline
Scalability
& 1) Huge requests to the \gls{sdn} controller
& \checkmark & & &
Limited \gls{sdn} controller capacity
\\ \cline{2-6}
& 2) Huge number of faults and alarms
& \checkmark & \checkmark & \checkmark
& Alarms correlation and fault detection
\\ \cline{2-6}
& 3) A growing number of tenants and resources
affectation
& & & \checkmark
& Optimization of resources allocation
\\ \hline
Topology
& 4) Dynamic topology
& & &
& Difficulty of modeling the network topology
\\ \cline{2-6}
& 5) Coexistence of Physical and virtual entities
& \checkmark & \checkmark & \checkmark
& Virtual and physical faults dependencies
\\ \cline{2-6}
& 6) Multi-tenants
& & & \checkmark
& Lack of network visibility
\\ \hline
Security
& 7) Attack on switches or controllers or control plane
& \checkmark & &
& Whole network disruption
\\ \cline{2-6}
& 8) Multi-tenant sharing the same infrastructure
& & & \checkmark
& Multi-tenants traffic isolation
\\ \hline
Fault Tolerance
& 9) A single \gls{sdn} controller a single point of failure
& \checkmark & &
& \gls{sdn} controller failure implies the whole network failure
\\ \cline{2-6}
& 10) Link failure
& \checkmark & \checkmark &
& Loss of network connection
\\ \cline{2-6}
& 11) End to End service chain crash
& & \checkmark &
& Rapid detection and recovery actions for clients services
\\ \cline{2-6}
& 12) Physical and virtual faults
& \checkmark & \checkmark &
& A physical failure may impact multiple virtual entities
\\ \cline{2-6}
& 13) Multi-tenants faults
& & & \checkmark
& The necessity of tenants faults isolation and notification
\\ \hline
Performance
& 14) \gls{sdn} controller and switch performance
&\checkmark & &
& Choose the best network configurations to have a high network resilience
\\ \cline{2-6}
& 15) Running environments
& & \checkmark &
& The performance of the \gls{vnf} depends on the running environment
\\ \cline{2-6}
& 16) Migration of tenants applications or \gls{vnf}
& & \checkmark & \checkmark
& Keep the same performance while migrating a tenant application or a \gls{vnf}
\\ \hline
\end{tabularx}
\end{sidewaystable}
\end{document}