我正在准备一份商业战略报告,该报告被分成了多个 tex 文件。其中一部分是关于竞争对手分析的,我想用表格来制作。
main.tex 中的声明如下:
\documentclass[9pt, a4paper, oneside]{book}
\usepackage{multirow} % Table
\usepackage{array} % Table
\usepackage{tabulary} % Table
\usepackage{graphicx} % Figure path
\usepackage{fancyhdr} % Page style
\usepackage{setspace} % Line space
\usepackage[parfill]{parskip} % Gap between paragraph instead indentation
\usepackage{pdflscape} % In order to adjust a large table
\usepackage{enumitem}
\usepackage{natbib} % Allows the user to switch between Harvard or numeric
分析表格分别包含在实质性章节中,
\input{competitors_list.tex}
该表声明如下,
\begin{landscape}
\normalsize
\noindent
\begin{tabulary}{.95\textwidth}{| >{\bfseries}l | l | l | l | l | l |}
\hline
Competitor & Profile & Product \& Service (incl. price) & Marketing Strategies & Advantages & Disadvantages \\\hline
% 2nd row
Company 1 &
\begin{minipage}[t]{.2\textwidth}
Company 1 provides the services
\end{minipage}
&
\begin{minipage}[t]{.2\textwidth}
\begin{itemize}
\item General service
\item Sepcific service
\end{itemize}
\end{minipage}
&
\begin{minipage}[t]{.2\textwidth}
\begin{itemize}
\item Official website
\item Advertisement
\end{itemize}
\end{minipage}
&
\begin{minipage}[t]{0.3\textwidth}
\begin{itemize}
\item Commercial union member
\end{itemize}
\end{minipage}
&
\begin{minipage}[t]{0.3\textwidth}
\begin{itemize}
\item Company size
\item Service categories
\end{itemize}
\end{minipage} \\ \hline
\end{tabulary}
\end{landscape}
上述代码确实生成了如下表格,
但是,当我想添加第三行时,
\begin{landscape}
\normalsize
\noindent
\begin{tabulary}{.95\textwidth}{| >{\bfseries}l | l | l | l | l | l |}
\hline
Competitor & Profile & Product \& Service (incl. price) & Marketing Strategies & Advantages & Disadvantages \\\hline
% 2nd row
Company 1 &
\begin{minipage}[t]{.2\textwidth}
Company 1 provides the services
\end{minipage}
&
\begin{minipage}[t]{.2\textwidth}
\begin{itemize}
\item General service
\item Sepcific service
\end{itemize}
\end{minipage}
&
\begin{minipage}[t]{.2\textwidth}
\begin{itemize}
\item Official website
\item Advertisement
\end{itemize}
\end{minipage}
&
\begin{minipage}[t]{0.3\textwidth}
\begin{itemize}
\item Commercial union member
\end{itemize}
\end{minipage}
&
\begin{minipage}[t]{0.3\textwidth}
\begin{itemize}
\item Company size
\item Service categories
\end{itemize}
\end{minipage} \\ \hline
% 3rd row
Company 2 &
\begin{minipage}
A big company provides
\end{minipage}
&
\begin{minipage}
\begin{itemize}
\item Project management
\end{itemize}
\end{minipage}
&
\begin{minipage}
\begin{itemize}
\item Official website
\end{itemize}
\end{minipage}
&
\begin{minipage}
\begin{itemize}
\item Large size
\end{itemize}
\end{minipage}
&
\begin{minipage}
\begin{itemize}
\item High price
\end{itemize}
\end{minipage} \\\hline
\end{tabulary}
\end{landscape}
编译时出现错误,
! Missing number, treated as zero.
<to be read again>
A
l.68 \end{tabulary}
我认为这可能是由于 \\ 和在每个 \\ 后添加 \relax 造成的。然后产生了新的错误,
! Misplaced \noalign.
\hline ->\noalign
{\ifnum 0=`}\fi \hrule \@height \arrayrulewidth \futurelet...
l.68 \end{tabulary}
另外,还有几个竞争对手需要添加,我需要切换吗表格到长桌空间不足的情况下?
抱歉,我对 Latex 的了解不够,非常感谢您的帮助。
答案1
与制表无关:您缺少所有新条目中的小页面宽度
\begin{minipage}
注意错误信息
! Missing number, treated as zero.
<to be read again>
\begin{minipage}
A
这表明错误的位置是A
\begin{minipage}
A
是相同的
\begin{minipage}{A}
因此它尝试读取A
长度,而长度以数字开头,因此您会收到错误,! Missing number, treated as zero.
行号显示为行,\end[tabulary}
因为整个环境在第一次传递时被读取到该点,以便包可以进行测量,因此 tex 会在出现此错误之前读到环境的末尾。