如何在 iopart 文檔類別中使用 \cases

如何在 iopart 文檔類別中使用 \cases

iopart文件類別在iopart.cls文件中定義了以下內容

\def\cases#1{%
     \left\{\,\vcenter{\def\\{\cr}\normalbaselines\openup1\jot\m@th%
     \ialign{\strut$\displaystyle{##}\hfil$&\tqs
     \rm##\hfil\crcr#1\crcr}}\right.}%

amsmath這是環境的替代品嗎cases?我該如何使用它?該定義出現在文件中的其他位置。

如何手動實現案例環境的問題已經被問到了這裡。我想知道考慮到該帖子的年齡,是否仍然需要這樣做。

答案1

\cases(不是環境)的這個定義是 LaTeX 內核中定義的修改,本質上與純 TeX 中的相同。

順便說一句,諸如\rm和 之類的命令\bf已經過時,並且已被棄用了近三十年。

有一個非常簡單的方法可以amsmath與 一起加載iopart。我還將使用一個技巧來比較iopart's\casesamsmath's的結果cases

\documentclass[10pt]{iopart}

% for using amsmath
\expandafter\let\csname equation*\endcsname\relax
\expandafter\let\csname endequation*\endcsname\relax

%%% This is just to compare the results
\let\iopartcases\cases
%%%

\usepackage{amsmath}

\begin{document}

In the following display I'll be using \verb|\cases| as
defined by \verb|iopart| in order to check the differences
\[
f(x)=\iopartcases{1 & abc \\ 0 & uvw}
\]
The following display will use \verb|cases| as defined by
\verb|amsmath| in order to check the differences
\[
f(x)=\begin{cases} 1 & abc \\ 0 & uvw \end{cases}
\]
Now we can decide which one to use.

\end{document}

在此輸入影像描述

如果您喜歡這種方式iopart,您可以定義一個iopcases環境(我不會覆蓋amsmath一個環境)。

\documentclass[10pt]{iopart}

% for using amsmath
\expandafter\let\csname equation*\endcsname\relax
\expandafter\let\csname endequation*\endcsname\relax

%%% This is just to compare the results
\let\iopartcases\cases
%%%

\usepackage{amsmath}
\usepackage{mathtools}

\makeatletter
\newcases{iopcases}{\tqs}
 {$\m@th\displaystyle##$\hfil}
 {##\hfil}
 {\lbrace}
 {.}
\makeatother

\begin{document}

In the following display I'll be using \verb|\cases| as
defined by \verb|iopart| in order to check the differences
\[
f(x)=\iopartcases{1 & abc \\ 0 & uvw}
\]
The following display will use \verb|iopcases| as defined
above in order to check the differences
\[
f(x)=\begin{iopcases} 1 & abc \\ 0 & uvw \end{iopcases}
\]
Now we can decide which one to use.

\end{document}

在此輸入影像描述

您想要像現在這樣的薄空間iopart嗎?變成

\makeatletter
\newcases{iopcases}{\tqs}
 {$\m@th\displaystyle\,##$\hfil}
 {##\hfil}
 {\lbrace}
 {.}
\makeatother

你會得到

在此輸入影像描述

我不會用於iopart私人目的。還有其他幾個課程不需要技巧就可以使用基本工具來排版數學。

相關內容