我在 Windows 10 上使用 Tex Studio。这是我正在执行的简单代码
\documentclass{article}
%\usepackage{siunitx}
%\sisetup{
%round-mode = places,
%round-precision = 2,
%}
\begin{document}
\begin{table}[h!]
\begin{center}
\begin{tabularx}{| X | X | X |}
\hline
\textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\\
$\alpha$ & $\beta$ & $\gamma$ \\
\hline
1 & 1110.1 & a \\
2 & 10.1 & b \\
3 & 23.113231 & c \\
\hline
\end{tabularx}
\end{center}
\caption{Your first label}
\label{tab:table1}
\end{table}
\begin{table} [h!]
\begin{center}
\begin{tabular}{|r | l |}
\hline
7C0 & hexadecimal \\
3700 & octal \\
\cline{2-2}} 11111000000 & binary \\
\hline
\end{tabular}
\end{center}
\caption{Your second label}
\label{tab:table2}
\end{table}
\begin{tabular}{cc}
boring cell content & \parbox[t]{5cm}{rather long par\\new par}
\end{tabular}
\end{document}
我点击了箭头
双箭头生成预览。我以前用乳胶写过论文,用过 Tex Studio。同样的笔记本电脑和同样的设置。所以我知道简单的代码编译并生成预览 pdf 不需要这么长时间。我做的很简单,我不清楚乳胶中表格的用法,所以我试着用给出的示例代码来练习https://en.wikibooks.org/wiki/LaTeX/Tables#The_tabularx_package和https://www.latex-tutorial.com/tutorials/tables/
所以我的程序是一些非常简单的代码片段,我正在尝试练习。上面发布的代码根本不需要很长时间来编译。那么我无法理解的问题是什么。如果这有帮助的话,这里是设置的预览
正如评论中所建议的,我查看了错误消息,以下是错误消息
Environment tabularx undefined. \begin{tabularx}
Misplaced \noalign. \hline
Misplaced alignment tab character &. \textbf{Value 1} &
Misplaced alignment tab character &. \textbf{Value 1} & \textbf{Value 2} &
Misplaced alignment tab character &. $\alpha$ &
Misplaced alignment tab character &. $\alpha$ & $\beta$ &
Misplaced \noalign. \hline
Misplaced alignment tab character &. 1 &
Misplaced alignment tab character &. 1 & 1110.1 &
Misplaced alignment tab character &. 2 &
Misplaced alignment tab character &. 2 & 10.1 &
Misplaced alignment tab character &. 3 &
Misplaced alignment tab character &. 3 & 23.113231 &
Misplaced \noalign. \hline
\begin{center} on input line 10 ended by \end{tabularx}. \end{tabularx}
Misplaced alignment tab character &. \cline{2-2}} 11111000000 &
正如评论中提到的,我删除了 cline 中的额外括号并包含了包 tabularx
\documentclass{article}
%\usepackage{siunitx}
%\sisetup{
%round-mode = places,
%round-precision = 2,
%}
\usepackage{tabularx}
\begin{document}
\begin{table}[h!]
\begin{center}
\begin{tabularx}{| X | X | X |}
\hline
\textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\\
$\alpha$ & $\beta$ & $\gamma$ \\
\hline
1 & 1110.1 & a \\
2 & 10.1 & b \\
3 & 23.113231 & c \\
\hline
\end{tabularx}
\end{center}
\caption{Your first label}
\label{tab:table1}
\end{table}
Second table
\begin{table} [h!]
\begin{center}
\begin{tabular}{|r | l |}
\hline
7C0 & hexadecimal \\
3700 & octal \\
\cline{2-2} 11111000000 & binary \\
\hline
\end{tabular}
\end{center}
\caption{Your second label}
\label{tab:table2}
\end{table}
\begin{tabular}{cc}
boring cell content & \parbox[t]{5cm}{rather long par\\new par}
\end{tabular}
\end{document}
现在我的错误是
line 12: Environment tabularx undefined. \begin{tabularx}
line 13: Misplaced \noalign. \hline
line 14: Misplaced alignment tab character &. \textbf{Value 1} &
line 14: Misplaced alignment tab character &. \textbf{Value 1} & \textbf{Value 2} &
line 15: Misplaced alignment tab character &. $\alpha$ &
line 15: Misplaced alignment tab character &. $\alpha$ & $\beta$ &
line 16: Misplaced \noalign. \hline
line 17: Misplaced alignment tab character &. 1 &
line 17: Misplaced alignment tab character &. 1 & 1110.1 &
line 18: Misplaced alignment tab character &. 2 &
line 18: Misplaced alignment tab character &. 2 & 10.1 &
line 19: Misplaced alignment tab character &. 3 &
line 19: Misplaced alignment tab character &. 3 & 23.113231 &
line 20: Misplaced \noalign. \hline
line 21: \begin{center} on input line 10 ended by \end{tabularx}. \end{tabularx}
line 33: Misplaced alignment tab character &. \cline{2-2}} 11111000000 &
答案1
Texstudio 中的红色二次按钮显示编译正在进行。当您想要取消该过程时,请按红色二次按钮。然后编译按钮将变为绿色。如果您使用 Miktex 安装“动态包”,则安装包时编译时间会更长。
答案2
\documentclass{article}
\usepackage{tabularx}
\usepackage{siunitx}
\usepackage{booktabs}
\sisetup{table-format=4.6,
round-mode = places,
round-precision = 2,
}
\begin{document}
\begin{table}
\centering
\begin{tabularx}{0.5\textwidth}{| c | S | c |}
\textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\\
$\alpha$ & $\beta$ & $\gamma$ \\
1 & 1110.1 & a \\
2 & 10.1 & b \\
3 & 23.113231 & c \\
\end{tabularx}
\caption{Your first label}
\label{tab:table1}
\vspace*{1cm}
\begin{tabular}{|r | l |} \hline
7C0 & hexadecimal \\
3700 & octal \\ \cline{2-2}
11111000000 & binary \\ \hline
\end{tabular} \\[1cm]
\begin{tabular}{cc}
boring cell content & \parbox[t]{5cm}{rather long par\\new par}
\end{tabular}
\end{table}
\end{document}