本地关闭一个包

本地关闭一个包

在下面的代码中,我想展示两种不同的格式样式:一种使用包nath输出,另一种显示默认输出。

我怎样才能做到这一点?

% Source : http://tex.stackexchange.com/questions/1023/vertically-asymmetric-size-variation-for-parentheses

\documentclass[10pt,a4paper]{article}
    \usepackage[utf8x]{inputenc}
    \usepackage{ucs}
    \usepackage{amsmath}
    \usepackage{amsfonts}
    \usepackage{amssymb}

    \usepackage{nath} % The usefull package.

    \newcommand{\formulaOne}{\sum_{0 \le i \le m \\ 0 < j < n} P(i,j)}
    \newcommand{\formulaTwo}{1 + \frac{1 + x^2}{1 - \frac{x}{2}}}


\begin{document}

\section{With nath}

\begin{equation}
    ( \formulaOne ) = [ \formulaTwo ]
\end{equation}


\section{Without nath}

\begin{equation}
    \left( \formulaOne \right) = \left[ \formulaTwo \right]
\end{equation}


\end{document}

答案1

这有效:

\documentclass[10pt,a4paper]{article}
\usepackage{amsmath}
\begin{document}

\section{Without nath}   
\begin{equation}
    \left( \sum_{0 \le i \le m \\ 0 < j < n} P(i,j) \right) 
    = \left[ 1 + \frac{1 + x^2}{1 - \frac{x}{2}} \right]
\end{equation}

\section{With nath}

\makeatletter
\input{nath.sty}
\makeatother
\begin{equation}
    ( \sum_{0 \le i \le m \\ 0 < j < n} P(i,j) ) 
      = [ 1 + \frac{1 + x^2}{1 - \frac{x}{2}} ]
\end{equation}

\end{document}

答案2

纳特该软件包改变了太多的默认设置,这样的项目即使可行(但我不这么认为),也需要付出巨大的努力。

最好的策略是使用独立类并将它们导入为 PDF 图形。

答案3

另一种方法是,你可以再次关闭 nath:

(如果发生任何故障,我不负责。这只在非常有限的情况下进行测试。)

基本上,有了这个序言,你就有了\enablenath\disablenath。尽管如此,这样做还是行不通,因为有和没有的\newcommand\formulaOne类别代码会发生变化。$^_nath

(当然,当调用unicode-math时会设置数学代码\AtBeginDocument,在这种情况下它可能不起作用)

%! TEX program = lualatex


% from https://tex.stackexchange.com/q/32148/250119

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}



{  % nath does not backup these 4, do it manually
\makeatletter
\catcode`*=11 %letter

\global\let\o@equation\equation
\global\let\o@equation*\equation*
\global\let\o@endequation\endequation
\global\let\o@endequation*\endequation*
}

\protected\def\foreachnathcommand#1{#1{addcontentsline}#1{array}#1{atop}#1{backslash}#1{bar}#1{begin}#1{bigcap}#1{bigcup}#1{bigodot}#1{bigoplus}#1{bigotimes}#1{bigsqcup}#1{biguplus}#1{bigvee}#1{bigwedge}#1{breve}#1{check}#1{choose}#1{coprod}#1{ddot}#1{display}#1{displaystyle}#1{dot}#1{dots}#1{downarrow}#1{Downarrow}#1{end}#1{endarray}#1{eqno}#1{er@}#1{fbox}#1{hat}#1{int}#1{label}#1{langle}#1{lbrace}#1{lbrack}#1{lceil}#1{left}#1{leqno}#1{lfloor}#1{math}#1{mathop}#1{oint}#1{over}#1{overline}#1{prod}#1{rangle}#1{rbrace}#1{rbrack}#1{rceil}#1{rfloor}#1{right}#1{scriptscriptstyle}#1{scriptstyle}#1{sqrt}#1{sum}#1{textstyle}#1{tilde}#1{underline}#1{uparrow}#1{Uparrow}#1{updownarrow}#1{Updownarrow}#1{vert}#1{Vert}#1{widehat}#1{widetilde}%
#1{equation}#1{endequation}#1{equation*}#1{endequation*}%
}

\protected\def\disablenathcommand#1{\expandafter \let \csname#1\expandafter\endcsname \csname o@#1\endcsname}
\protected\def\enablenathcommand#1{\expandafter \let \csname#1\expandafter\endcsname \csname nath@#1\endcsname}

\protected\edef\disablenath{%
\catcode`$=3
\catcode`^=7
\catcode`_=8
\mathcode`(=\the\mathcode`(
\mathcode`[=\the\mathcode`[
\mathcode`<=\the\mathcode`<
\mathcode`)=\the\mathcode`)
\mathcode`]=\the\mathcode`]
\mathcode`>=\the\mathcode`>
\mathcode`,=\the\mathcode`,
\mathcode`;=\the\mathcode`;
\mathcode`!=\the\mathcode`!
\mathcode``=\the\mathcode``
\foreachnathcommand\disablenathcommand
}

\protected\def\enablenath{%
\catcode`$=12
\catcode`^=12
\catcode`_=12
\mathcode`(="8000
\mathcode`[="8000
\mathcode`<="8000
\mathcode`)="8000
\mathcode`]="8000
\mathcode`>="8000
\mathcode`,="8000
\mathcode`;="8000
\mathcode`!="8000
\mathcode``="8000
\foreachnathcommand\enablenathcommand
}


\usepackage{nath}

\protected\def\savenathcommand#1{\expandafter \let \csname nath@#1\expandafter\endcsname \csname #1\endcsname}
\foreachnathcommand\savenathcommand
\disablenath





\begin{document}

\section{With nath}

\enablenath

\begin{equation}
    ( 
        \sum_{0 \le i \le m \\ 0 < j < n} P(i,j)
    ) = [
        1 + \frac{1 + x^2}{1 - \frac{x}{2}}
    ]
\end{equation}

\section{Without nath}

\disablenath

\begin{equation}
    \left( 
        \sum_{\substack{0 \le i \le m \\ 0 < j < n}} P(i,j)
    \right) = \left[
        1 + \frac{1 + x^2}{1 - \frac{x}{2}}
    \right]
\end{equation}

\section{With nath (again)}

\enablenath

\begin{equation}
    ( 
        \sum_{0 \le i \le m \\ 0 < j < n} P(i,j)
    ) = [
        1 + \frac{1 + x^2}{1 - \frac{x}{2}}
    ]
\end{equation}

\end{document}

输出

相关内容