以下文档在 TexStudio v.4.5.2 中正常结束,但环境\\
中的命令上带有红色标记tabular
。
\documentclass{article}
\usepackage{array}
\usepackage{enumerate}
\renewcommand{\arraystretch}{1.5}
%% Setting questions
\newcommand{\q}[2]{#1 \textbf{\textit{[QB-#2]}}}
\begin{document}
\begin{enumerate}
\item \q{A refrigerator based on ideal vapour compression cycle operates between the temperature limits of $-20^\circ$ and $40^\circ$. The refrigerant enters the condenser as saturated vapour and leaves as saturated liquid. The enthalpy and entropy values for saturated liquid and vapour at these temperature are given in the table below:}{411}
\begin{center}
\begin{tabular}{ | c | wc{1cm} | wc{1cm} | wc{1cm} | wc{1cm} | }
\firsthline
Temperature & $h_f$ & $h_g$ & $S_f$ & $S_g$\\
\hline
$\left(^\circ C\right)$ & \multicolumn{4}{c |}{$\left(KJ/Kg\right)$}\\
\hline
-20 & 20 & 180 & 0.07 & 0.7366\\
\hline
40 & 80 & 200 & 0.3 & 0.67\\
\lasthline
\end{tabular}
\end{center}
\end{enumerate}
\end{document}
这里有什么问题?
答案1
tabularray
我将使用表格、siunitx
单位、数量和定义S
列类型来编写表格:
\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}
\sisetup{per-mode = symbol}
\usepackage{enumerate}
\renewcommand{\arraystretch}{1.5}
%% Setting questions
\newcommand{\q}[2]{#1 \textbf{\textit{[QB-#2]}}}
\begin{document}
\begin{enumerate}
\item \q{A refrigerator based on ideal vapour compression cycle operates between the temperature limits of \qty{-20}{\degreeCelsius} and \qty{40}{\degreeCelsius}. The refrigerant enters the condenser ass saturated vapour and leaves as saturated liquid. The enthalpy and entropy values for saturated liquid and vapour at these temperature are given in the table below:}{411}
\begin{center}
\begin{tblr}{hlines, vlines,
colspec = { Q[c, si={table-format=-2.0}]
*{2}{Q[c, wd=1cm]}
Q[c, wd=1cm, si={table-format=1.2}]
Q[c, wd=1cm, si={table-format=1.4}]},
cell{1}{2-Z} = {mode=math},
row{1,2} = {guard}
}
Temperature & h_f & h_g & S_f & S_g \\
(\si{\degreeCelsius})
& \SetCell[c=4]{c} (\si{\kilo\joule\per\kilo\gram})
& & & \\
-20 & 20 & 180 & 0.07 & 0.7366 \\
40 & 80 & 200 & 0.3 & 0.67 \\
\end{tblr}
\end{center}
\end{enumerate}
\end{document}
所提出的解决方案独立于所使用的 LaTeX 实现(应为最新版本)和编辑器。