Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to control the width of the equations so they don't exceed a predefined width. Firstly I used minipage environment and put the eqnarray within that. This does not produce the line breaks before and after the equations. I manually use line break, then there would be extra space between text and equations. Is there any other way to set an specific width for an equation without affecting the line breaks? I specifically want to use eqnarray and not any other environments like align for typesetting equations.

\documentclass[]{article}
    \newenvironment{myenv}{ \begin{minipage}{5cm}\begin{eqnarray}
      }{\end{eqnarray}\end{minipage} }

\begin{document}


dummy text here
\begin{myenv}
  a &= s^3-s
  \\
  b &=s^2+s
\end{myenv}
dummy text here

\end{document}

enter image description here

with added line breaks:

\newenvironment{myenv}{\\ \begin{minipage}{5cm}\begin{eqnarray}
  }{\end{eqnarray}\end{minipage} \\}

enter image description here

share|improve this question
    
It's best to avoid \eqnarray. See \eqnarray vs \align. –  Werner Jan 29 '13 at 15:35
    
@ Wener: Thanks, I know about it. However due to some limitations of the class file I am using I can only use eqnarray and not align. –  M.Reza Jan 29 '13 at 15:42
    
Could you elaborate on what prevents you from using align? It really is a better tool for the job. I would sooner forego numbering entirely using \[ maths \], or try to figure out how to do the equation numbering by hand, than use the equation spacing we see in your two examples. –  Niel de Beaudrap Jan 29 '13 at 16:15
    
@ Niel de Beaudrap: The reason is that, I am using iopart document class which is not compatible with amsmath. A related post can be seen here tex.stackexchange.com/questions/95817/… –  M.Reza Jan 29 '13 at 16:29
    
have a look at adjustwidth from the changepage package- it should help with what you want... –  cmhughes Jan 29 '13 at 16:40

1 Answer 1

up vote 3 down vote accepted

enter image description here

\documentclass[]{article}
    \newenvironment{myenv}[1]
{\everydisplay{\setlength\displaywidth{#1}}\begin{eqnarray}}
{\end{eqnarray}\ignorespacesafterend}


\begin{document}

\noindent X\dotfill X

dummy text here X\dotfill X
\begin{myenv}{5cm}
  a &= s^3-s
  \\
  b &=s^2+s
\end{myenv}
dummy text here

dummy text here  X\dotfill X
\begin{myenv}{3cm}
  a &= s^3-s
  \\
  b &=s^2+s
\end{myenv}
dummy text here

dummy text here  X\dotfill X
\begin{myenv}{10cm}
  a &= s^3-s
  \\
  b &=s^2+s
\end{myenv}
dummy text here

\end{document}
share|improve this answer
    
Thanks David for your answer! This method seems to also affect the width of the paragraph coming before \begin{myenv}{?}. It would be clear if a longer dummy text is used before the new environment. –  M.Reza Jan 29 '13 at 18:31
    
sorry, code fixed. –  David Carlisle Jan 29 '13 at 20:05
    
Thanks it works well. I am accepting it as answer since my problem might be too specific; I'm not sure however, why this does not work with eqnarray defined in iopart, when using \documentclass[12pt]{iopart} it doesn't have any effect. –  M.Reza Jan 29 '13 at 20:40
2  
just googled for a copy of iopart: change \displaywidth to \linewidth for their version –  David Carlisle Jan 29 '13 at 20:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.