11

In the following code, I would like to show two different formatting styles: one using the package nath output, and another showing the default output.

How can I do that?

% 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

3 Answers 3

12

this works:

\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}
16

The nath package changes too much of the default setting that such a project, even if it was feasible (I don't think so, though), would require a gigantic effort.

The best strategy is to prepare the samples with the standalone class and to import them as PDF graphics.

1
  • While Herbert's answer apparently works in this instance, I think this answer is the more generally applicable...
    – Seamus
    Oct 20, 2011 at 14:08
1

An alternative, where you can turn off nath again:

(I'm not responsible if anything breaks. This is only tested in very limited cases.)

Basically with that preamble you have \enablenath and \disablenath. Nevertheless, it doesn't work to do \newcommand\formulaOne because the category code of $^_ changes with and without nath.

(naturally, as unicode-math sets the math code when \AtBeginDocument is called, it will probably not work in that case)

%! 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}

output

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .