我使用!{=}
数组来构建紧凑方程,但在最后一行,我希望使用\approx
而不是=
。
是否可以 ?
\documentclass{standalone}
\usepackage{array,tabularx}
\begin{document}
$\begin{array}{r!{=}l}
TS &TU \times\cos\hat{T} \\
&7.5\times\cos\,41.5\\
&5.6\\ % \approx here instead of =
\end{array}$
\end{document}
答案1
我不确定这是否真的节省时间。
\documentclass[border=2]{standalone}
\usepackage{array}
\newcommand{\noeq}[1]{\multicolumn{1}{r!{#1}}{}}
\begin{document}
$\begin{array}{r!{=}l}
TS &TU \times\cos\hat{T} \\
&7.5\times\cos 41.5 \\
\noeq{\approx} &5.6
\end{array}$
\end{document}
我会这样做;请注意,间距是关系符号周围的正常间距。
\documentclass[border=2]{standalone}
\usepackage{array}
\begin{document}
$\begin{array}{r@{}>{{}}l}
TS &= TU \times\cos\hat{T} \\
&= 7.5\times\cos 41.5 \\
&\approx 5.6
\end{array}$
\end{document}
这可能更有吸引力,因为它会自动照顾两侧的空间。
\documentclass[border=2]{standalone}
\usepackage{amsmath}
\begin{document}
$\begin{aligned}
TS &= TU \times\cos\hat{T} \\
&= 7.5\times\cos 41.5 \\
&\approx 5.6
\end{aligned}$
\end{document}
答案2
为了获得额外的灵活性,请考虑创建一个 3 列array
,其中中间列包含关系运算符 ——=
或者\approx
。
\documentclass{article}
\usepackage{array} % for "\newcolumntype" macro
\newcolumntype{C}{>{{}}c<{{}}}
\begin{document}
$\setlength\arraycolsep{0pt}
\begin{array}{rCl}
TS &=&TU \times\cos\hat{T} \\
&=&7.5\times\cos\,41.5\\
&\approx&5.6
\end{array}$
\end{document}
答案3
\documentclass{standalone}
\usepackage{array}
\newif\ifUseApprox
\protected\def\Equal{\ifUseApprox\approx\else=\fi}
\def\EqualUseApprox{\global\UseApproxtrue}
\def\EqualUseEqual {\global\UseApproxfalse}
\begin{document}
$\begin{array}{r!{\Equal}l}
TS &TU \times\cos\hat{T} \\
&7.5\times\cos\,41.5\\
\EqualUseApprox &5.6\\ % \approx here instead of =
\end{array}$
\end{document}
\documentclass[varwidth, border=10pt]{standalone}
\usepackage{array, shortvrb}
\newif\ifUseApprox
\protected\def\Equal{\ifUseApprox\approx\else=\fi}
\def\EqualUseApprox{\global\UseApproxtrue}
\def\EqualUseEqual {\global\UseApproxfalse}
\begin{document}
\hsize 6cm
$\begin{array}{r!{\Equal}l}
TS &TU \times\cos\hat{T} \\
&7.5\times\cos\,41.5\\
\EqualUseApprox &5.6\\ % \approx here instead of =
\end{array}$
I now want to have a line \verb|\approx 7.5\times 0.75|
followed by a line with \verb|= 5.63| !
\EqualUseEqual % reset
$\begin{array}{r!{\Equal}l}
TS &TU \times\cos\hat{T} \\
&7.5\times\cos\,41.5\\
\EqualUseApprox &5.6\\ % \approx here instead of =
&7.5\times 0.75\\
\EqualUseEqual &5.63\\ % again using =
\end{array}$
\end{document}