3

adjustwidth inserts a redundant newline only when it is used with eqnarray. How can I avoid it?

Input:

\documentclass{article}
\usepackage{changepage}

\begin{document}

\noindent
Hello World!
\begin{adjustwidth}{-1cm}{-1cm}
Hello World!
\end{adjustwidth}

\ \\
Hello World!
\begin{eqnarray}
f(x) = 1
\end{eqnarray}

\ \\
Hello World!
\begin{adjustwidth}{-1cm}{-1cm}
\begin{eqnarray}
f(x) = 1
\end{eqnarray}
\end{adjustwidth}

\end{document}

Output:

enter image description here

Output with caption:

enter image description here

As far as I measure with a ruler, the height of the space is doubled when with adjustwidth.


MWE input:

\documentclass{article}
\usepackage[top=30truemm,bottom=30truemm,left=25truemm,right=25truemm]{geometry}

\usepackage{changepage}
\usepackage{braket}
\usepackage{bm}

\newcommand{\bmk}{{\bm{k}}}
\newcommand{\brac}[1]{\left( #1 \right)}
\newcommand{\expo}[1]{e^{#1}}
\newcommand{\ao}[1]{a_{#1}}
\newcommand{\aod}[1]{a^\dagger _{#1}}

\begin{document}

Operator $A$ is defined as
\begin{eqnarray}
A &=& \sum _{\bmk _1, \bmk _2} \Braket{\bmk _1, \uparrow | \hat{A} | \bmk _2, \uparrow} \left\{ \brac{\cos \theta _{\bmk _1} \cos \theta _{\bmk _2} - \eta \sin \theta _{\bmk _1} \sin \theta _{\bmk _2}} \brac{\aod{\bmk _1, \uparrow} \ao{\bmk _2, \uparrow} + \eta \aod{- \bmk _2, \downarrow} \ao{- \bmk _1, \downarrow}} \right. \nonumber \\
&\ & \hspace{3cm} \left. + \brac{\cos \theta _{\bmk _1} \sin \theta _{\bmk _2} + \eta \sin \theta _{\bmk _1} \cos \theta _{\bmk _2}} \brac{\aod{\bmk _1, \uparrow} \aod{- \bmk _2, \downarrow} + \eta \ao{- \bmk _1, \downarrow} \ao{\bmk _2, \uparrow}} \right\}.
\end{eqnarray}

The Heisenberg representation of this gives 
\begin{eqnarray}
A(t) &=& \sum _{\bmk _1, \bmk _2} \Braket{\bmk _1, \uparrow | \hat{A} | \bmk _2, \uparrow} \left\{ \brac{\cos \theta _{\bmk _1} \cos \theta _{\bmk _2} - \eta \sin \theta _{\bmk _1} \sin \theta _{\bmk _2}} \brac{\aod{\bmk _1, \uparrow} \ao{\bmk _2, \uparrow} \expo{\frac{i}{\hbar} (E_{\bmk _1} - E_{\bmk _2}) t} + \eta \aod{- \bmk _2, \downarrow} \ao{- \bmk _1, \downarrow} \expo{- \frac{i}{\hbar} (E_{\bmk _1} - E_{\bmk _2}) t}} \right. \nonumber \\
&\ & \hspace{1.5cm} \left. + \brac{\cos \theta _{\bmk _1} \sin \theta _{\bmk _2} + \eta \sin \theta _{\bmk _1} \cos \theta _{\bmk _2}} \brac{\aod{\bmk _1, \uparrow} \aod{- \bmk _2, \downarrow} \expo{\frac{i}{\hbar} (E_{\bmk _1} + E_{\bmk _2}) t} + \eta \ao{- \bmk _1, \downarrow} \ao{\bmk _2, \uparrow} \expo{- \frac{i}{\hbar} (E_{\bmk _1} + E_{\bmk _2}) t} } \right\}.
\end{eqnarray}

The Heisenberg representation of this gives 
\begin{adjustwidth}{-1cm}{-1cm}
\begin{eqnarray}
A(t) &=& \sum _{\bmk _1, \bmk _2} \Braket{\bmk _1, \uparrow | \hat{A} | \bmk _2, \uparrow} \left\{ \brac{\cos \theta _{\bmk _1} \cos \theta _{\bmk _2} - \eta \sin \theta _{\bmk _1} \sin \theta _{\bmk _2}} \brac{\aod{\bmk _1, \uparrow} \ao{\bmk _2, \uparrow} \expo{\frac{i}{\hbar} (E_{\bmk _1} - E_{\bmk _2}) t} + \eta \aod{- \bmk _2, \downarrow} \ao{- \bmk _1, \downarrow} \expo{- \frac{i}{\hbar} (E_{\bmk _1} - E_{\bmk _2}) t}} \right. \nonumber \\
&\ & \hspace{1.5cm} \left. + \brac{\cos \theta _{\bmk _1} \sin \theta _{\bmk _2} + \eta \sin \theta _{\bmk _1} \cos \theta _{\bmk _2}} \brac{\aod{\bmk _1, \uparrow} \aod{- \bmk _2, \downarrow} \expo{\frac{i}{\hbar} (E_{\bmk _1} + E_{\bmk _2}) t} + \eta \ao{- \bmk _1, \downarrow} \ao{\bmk _2, \uparrow} \expo{- \frac{i}{\hbar} (E_{\bmk _1} + E_{\bmk _2}) t} } \right\}.
\end{eqnarray}
\end{adjustwidth}

\end{document}

MWE output:

enter image description here

Eq(2) is written without adjustwidth. That is enough when I see the pdf on my computer, but the right edge part will vanish when printed. Eq(3) is written with adjustwidth. Is is readable and printable. However, there is a redundant space inserted. (In Eq(2) or Eq(3), a single equation is broken into two lines. I don't wanna break the equation anymore (into three or more lines).)

  • 1
    (i) instead eqnarray` is better to use align or similar math environment from asmath package, (ii) for one line equation the use of multi line math environment hasn't any sense (iii) for what purposes you insert equations into reduced text width (made byadjustwidth), and not at the end, (iv) please extend your code fragment to complete small document (MWE: Minimal Working Example), which reproduce your problem and which we can test as it is. – Zarko Aug 8 at 13:02
  • @Zarko Thank you for you comment. (i) I know... (ii) I know. (iii)(iv) Please see my edit. I added MWE. – ynn Aug 8 at 13:23
  • if you know, why than you useeqnarray? after editing your question it seems that use of multline would be better. – Zarko Aug 8 at 13:39
3

I suggest split. Never use eqnarray with LaTeX, prefer the alignment environments offered by amsmath.

\documentclass{article}
\usepackage[top=30truemm,bottom=30truemm,left=25truemm,right=25truemm]{geometry}

\usepackage{amsmath}
\usepackage{changepage}
\usepackage{braket}
\usepackage{bm}

\newcommand{\bmk}{\bm{k}}
\newcommand{\brac}[1]{\left( #1 \right)}
\newcommand{\expo}[1]{e^{#1}}
\newcommand{\ao}[1]{a_{#1}}
\newcommand{\aod}[1]{a^\dagger_{#1}}
\newcommand{\up}{{\uparrow}}
\newcommand{\down}{{\downarrow}}

\begin{document}

Operator $A$ is defined as
\begin{equation}
\begin{split}
A = 
\sum_{\bmk_1, \bmk_2} \braket{\bmk_1, \up | \hat{A} | \bmk_2, \up} \bigl\{
& 
  (\cos\theta_{\bmk_1} \cos\theta_{\bmk_2} - \eta \sin\theta_{\bmk_1} \sin\theta_{\bmk_2})
  (\aod{\bmk_1, \up} \ao{\bmk_2, \up} + \eta \aod{- \bmk_2, \down} \ao{- \bmk_1, \down}) \\
{}+{} &
  (\cos\theta_{\bmk_1} \sin\theta_{\bmk_2} + \eta \sin\theta_{\bmk_1} \cos\theta_{\bmk_2})
  (\aod{\bmk_1, \up} \aod{- \bmk_2, \down} + \eta \ao{- \bmk_1, \down} \ao{\bmk_2, \up})
  \bigr\}.
\end{split}
\end{equation}
The Heisenberg representation of this gives 
\begin{equation}
\begin{split}
A(t) = \sum_{\bmk_1, \bmk_2} &\braket{\bmk_1, \up | \hat{A} | \bmk_2, \up}
\\
{}\cdot\bigl\{&
  (\cos\theta_{\bmk_1} \cos\theta_{\bmk_2} - \eta \sin\theta_{\bmk_1} \sin\theta_{\bmk_2})
  (\aod{\bmk_1, \up} \ao{\bmk_2, \up} \expo{\frac{i}{\hbar} (E_{\bmk_1} - 
    E_{\bmk_2}) t} + \eta \aod{- \bmk_2, \down} \ao{- \bmk_1, \down} 
    \expo{- \frac{i}{\hbar} (E_{\bmk_1} - E_{\bmk_2}) t})
\\
{}+{}&
  (\cos\theta_{\bmk_1} \sin\theta_{\bmk_2} + \eta \sin\theta_{\bmk_1} \cos\theta_{\bmk_2})
  (\aod{\bmk_1, \up} \aod{- \bmk_2, \down} \expo{\frac{i}{\hbar} (E_{\bmk_1} + E_{\bmk_2}) t} +
     \eta \ao{- \bmk_1, \down} \ao{\bmk_2, \up} 
     \expo{- \frac{i}{\hbar} (E_{\bmk_1} + E_{\bmk_2}) t}) \bigl\}.
\end{split}
\end{equation}

\end{document}

enter image description here

Some notes: I removed all \left and \right commands, that give too big fences all around. Also I defined \up and \down, because \uparrow and \downarrow are relation symbols and may produce bad spacing if used as ordinary symbols. The braces in the definition make \up and \down behave like ordinary symbols everywhere.

1

First off, don't use eqnarray -- use align instead. Second, no need to resort to adjustwidth sledgehammer if you insert a few additional line breaks. For enhanced readability, consider using \exp-notation inside the \expo macro, as is done in the following screenshot.

enter image description here

\documentclass{article}
\usepackage[vmargin=3cm,hmargin=2.5cm]{geometry}
\usepackage{amsmath}
\allowdisplaybreaks
\usepackage{changepage}
\usepackage{braket}
\usepackage{bm}

\newcommand{\bmk}{{\bm{k}}}
\newcommand{\brac}[1]{\Bigl( #1 \Bigr)}
\newcommand{\expo}[1]{\exp\bigl(#1\bigr)}
\newcommand{\ao}[1]{a^{\vphantom{\dagger}}_{#1}}
\newcommand{\aod}[1]{a^\dagger _{#1}}

\begin{document}

Operator $A$ is defined as
\begin{align}
A &= \sum _{\bmk _1, \bmk _2} 
\Braket{\bmk _1, \uparrow | \hat{A} | \bmk _2, \uparrow}
\Bigl\{ 
  \brac{\cos \theta _{\bmk _1} \cos \theta _{\bmk _2} 
  - \eta \sin \theta _{\bmk _1} \sin \theta _{\bmk _2}} \notag\\
&\qquad\times\brac{\aod{\bmk _1, \uparrow} \ao{\bmk _2, \uparrow} 
  + \eta \aod{- \bmk _2, \downarrow} \ao{- \bmk _1, \downarrow}} \nonumber \\
&\quad+ \brac{\cos \theta _{\bmk _1} \sin \theta _{\bmk _2} 
  + \eta \sin \theta _{\bmk _1} \cos \theta _{\bmk _2}} 
  \brac{\aod{\bmk _1, \uparrow} \aod{- \bmk _2, \downarrow} 
  + \eta \ao{- \bmk _1, \downarrow} \ao{\bmk _2, \uparrow}}
\Bigr\}.\\
\intertext{The Heisenberg representation of this gives}
A(t) &= \sum _{\bmk _1, \bmk _2}
\Braket{\bmk _1, \uparrow | \hat{A} | \bmk _2, \uparrow}
\Bigl\{
  \brac{\cos \theta _{\bmk _1} \cos \theta _{\bmk _2} 
  - \eta \sin \theta _{\bmk _1} \sin \theta _{\bmk _2}} \notag\\
&\qquad\times\brac{\aod{\bmk _1, \uparrow} \ao{\bmk _2, \uparrow} 
  \expo{\tfrac{i}{\hbar} (E_{\bmk _1} - E_{\bmk _2}) t} 
  + \eta \aod{- \bmk _2, \downarrow} \ao{- \bmk _1, \downarrow} 
  \expo{- \tfrac{i}{\hbar} (E_{\bmk _1} - E_{\bmk _2}) t}} \nonumber \\
&\quad + \brac{\cos \theta _{\bmk _1} \sin \theta _{\bmk _2} 
  + \eta \sin \theta _{\bmk _1} \cos \theta _{\bmk _2}} \notag\\
&\qquad\times\brac{\aod{\bmk _1, \uparrow} \aod{- \bmk _2, \downarrow} 
  \expo{\tfrac{i}{\hbar} (E_{\bmk _1} + E_{\bmk _2}) t} 
  + \eta \ao{- \bmk _1, \downarrow} \ao{\bmk _2, \uparrow} 
  \expo{- \tfrac{i}{\hbar} (E_{\bmk _1} + E_{\bmk _2}) t} } 
\Bigr\}\,.
\end{align}

\end{document}
1

The source code changepage.sty shows

\newenvironment{adjustwidth}[2]{%
  \begin{list}{}{%
    \topsep\z@%
    \listparindent\parindent%
    \parsep\parskip%
    \@ifmtarg{#1}{\setlength{\leftmargin}{\z@}}%
                 {\setlength{\leftmargin}{#1}}%
    \@ifmtarg{#2}{\setlength{\rightmargin}{\z@}}%
                 {\setlength{\rightmargin}{#2}}%
    }
    \item[]}{\end{list}}

(These links may help you understand the code above: What does \z@ do? and \topsep, \itemsep, \partopsep and \parsep - what does each of them mean (and what about the bottom)?)

So the problem is not due to adjustwidth but due to eqnarray. The list environment gives you one line for an item, but eqnarray automatically inserts a newline, so the space is widened. Margin settings are irrelevant, and the same problem can be reproduced with itemize. For example,

Input:

\documentclass{article}

\begin{document}

\begin{itemize}
\item
\begin{eqnarray}
f(x) = 1
\end{eqnarray}
\end{itemize}

\begin{itemize}
\item Hello
\begin{eqnarray}
f(x) = 1
\end{eqnarray}
\end{itemize}

\end{document}

Output:

enter image description here

So the solution is to move the text into adjustwidth environment.

Input:

\documentclass{article}
\usepackage[top=30truemm,bottom=30truemm,left=25truemm,right=25truemm]{geometry}
\usepackage{changepage}

\begin{document}

\ \\ % normal
Hello World!
\begin{eqnarray}
f(x) = 1
\end{eqnarray}

\ \\ % with adjustwidth
Hello World!
\begin{adjustwidth}{-1cm}{-1cm}
\begin{eqnarray}
f(x) = 1
\end{eqnarray}
\end{adjustwidth}

\ \\ % solution
\begin{adjustwidth}{-1cm}{-1cm}
\hspace{1.0cm}Hello World! % note that this text is INSIDE the environment
\begin{eqnarray}
f(x) = 1
\end{eqnarray}
\end{adjustwidth}

\end{document}

Output:

enter image description here

This is what I wanted though this sticks to deprecated eqnarray...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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