3

Is there any simple (method/macro,..) to replace everything inside all eqnarray* by a simple given text. More precisely for example I want to replace

\begin{eqnarray*}
x     & = & \frac{1}{2}at_1^2 + v_0t_1 + x_0\\
t_1^2 & = & \frac{2x}{g}
\end{eqnarray*}

or any eqnarray* by

\begin{eqnarray*}
\text{Math inside}
\end{eqnarray*}

best regards.

Edit: it would be nice if this also works for align, displaymath,.... It should save the environment structure, and replace the content inside it.

Troy
  • 13,741
user31009
  • 273
  • 2
    First of all, don't use eqnarray... See why here: http://www.tug.org/TUGboat/tb33-1/tb103madsen.pdf. Then, what you want is: whenever you use one of those environments, you want a simple text to be printed instead of its contents? – karlkoeller Nov 19 '13 at 15:05
  • 1
    Do you have any approaches yourself yet? It would be interesting to have them as a starting point, or you could explain a little more, what you want to achieve in total (hand out a script where the formulae are missing, so that the students can fill that out while attending the lecture?) – Ronny Nov 19 '13 at 15:06
  • The answers here may solve your problem: http://tex.stackexchange.com/questions/9771/how-to-redefine-via-environ-package-the-pmatrix-environment – Ethan Bolker Nov 19 '13 at 15:09

3 Answers3

2

Here is a method using the environ package.

\documentclass{article}
\usepackage{environ}
\usepackage{amsmath}
\newif\ifprintmaths
\printmathsfalse % <--- Change to true to switch maths printing on.
\NewEnviron{myalign}
{\ifprintmaths
  \begin{align}\BODY\end{align}
\else
  \centering Maths printing off. \par
\fi}{}
\begin{document}
\begin{myalign}
A &= B \\
C &= D
\end{myalign}
\end{document}
Troy
  • 13,741
Ian Thompson
  • 43,767
1

Is this what you mean? I should point out that it can only handle as many fields as I put c's in the array field.

\documentclass{article}
\usepackage{amsmath}
\newsavebox\mybox
\renewenvironment{eqnarray*}
{\par Math Inside\par\lrbox{\mybox}$\array{cccccccccccccc}}
{\endarray$\endlrbox}
\begin{document}
Here is pre text
\begin{eqnarray*}
x     & = & \frac{1}{2}at_1^2 + v_0t_1 + x_0\\
t_1^2 & = & \frac{2x}{g}
\end{eqnarray*}
Here is post text
\end{document}
Troy
  • 13,741
0

I am not sure what you're actually trying to achieve, but it sounds more like a job for text editors rather than macros. For instance, if you use Notepad++, you can do the following: Go to Search -> Replace, then type

\\begin\{eqnarray\*\}.*?\\end\{eqnarray\*\}

in the Find what box, and

\\begin\{eqnarray\*\}\r\\text\{Math inside\}\r\\end\{eqnarray\*\}

in the Replace with box. Now check Wrap Around, Regular expression and . matches newline boxes, then click Replace All.

enter image description here

Francis
  • 6,183