5

It seems that nccmath is affecting the layout of minipages. In the MWE, you can see the left minipage is clearly not taking up 70% of the page as I wanted. I'm hoping that there is an easy fix for this, otherwise I need to get rid of nccmath.

I have had problems with nccmath previously as discussed in Alignment of item number in list containing a minipage so I'm wondering if I should try to work without that package.

\documentclass[fleqn,preview=false]{standalone}

\usepackage{amsmath}
\usepackage{nccmath}% Needed for fleqn environment

\begin{document}
\begin{minipage}{0.70\linewidth}
\begin{align*}
    y &= x 
\end{align*}
\end{minipage}
\begin{minipage}{0.30\linewidth}
    Note: abcd
\end{minipage}
\end{document}
Peter Grill
  • 223,288

3 Answers3

5

It appears that nccmath indeed breaks minipages containing only a math display, setting them to have the width resulting from adding the space on the left of the display and the equation width.

If the minipage contains "paragraph material", its width is correctly set.

Solution: start a minipage that should contain only a display with

\hrule height 0pt width \hsize

Some examples (in the code the \hrule has a height in order to make it visible)

\documentclass[a4paper,fleqn]{article}

\usepackage{amsmath}
\usepackage{nccmath}% Needed for fleqn environment

\begin{document}
% let's have a "ruler"
\hbox to\hsize{\leaders\hrule\hskip0pt plus 7fill
  \kern-.2pt\vrule depth 2pt\kern-.2pt
  \leaders\hrule\hskip0pt plus 3fill}
\medskip

Example 1: we put a rule with the desired width

\noindent\begin{minipage}{0.70\columnwidth}
\hrule width \hsize\kern-.4pt
\begin{align*}
    y &= x 
\end{align*}
\end{minipage}%
\begin{minipage}{0.30\columnwidth}
\hrule
    Note: abcd

Where should this go?
\hrule
\end{minipage}

\medskip

Example 2: we don't specify the rule's width

\noindent\begin{minipage}{0.70\columnwidth}
\hrule\kern-.4pt
\begin{align*}
    y &= x 
\end{align*}
\end{minipage}%
\begin{minipage}{0.30\columnwidth}
\hrule
    Note: abcd

Where should this go?
\hrule
\end{minipage}

\medskip

Example 3: text before the display

\noindent\begin{minipage}{0.70\columnwidth}
\hrule\kern-.4pt
Some text before
\begin{align*}
    y &= x 
\end{align*}
\end{minipage}%
\begin{minipage}{0.30\columnwidth}
\hrule
    Note: abcd

Where should this go?
\hrule
\end{minipage}

\medskip

Example 4: text below the display

\noindent\begin{minipage}{0.70\columnwidth}
\hrule\kern-.4pt
\begin{align*}
    y &= x 
\end{align*}
Some text below
\end{minipage}%
\begin{minipage}{0.30\columnwidth}
\hrule
    Note: abcd

Where should this go?
\hrule
\end{minipage}

\end{document}

output of code

Alan Munn
  • 218,180
egreg
  • 1,121,712
4

In the comment within your code I see you need nccmath for the fleqn environment. You can define that environment yourself in your preamble without loading nccmath. You can use the code from that package:

\makeatletter
\newenvironment*{fleqn}[1][\z@]{\@fleqntrue
  \setlength\@mathmargin{#1}\ignorespaces
}{%
  \ignorespacesafterend
}
\makeatother
lockstep
  • 250,273
Stefan Kottwitz
  • 231,401
  • Excellent suggestion. But, in case I need other things from nccmath later, I think I'll leave it in my common preamble. Taking it out now and putting it back in seems that it might result in a lot of additional work later. Do you know if the features of nccmath package have been implemented elsewhere? – Peter Grill Jul 02 '11 at 17:59
0

The bug is due to \NCC@ignorepar command in nccmath package:

"This command removes extra vertical space before display formula if it starts from a new paragraph and changes the beforeskip to \abovedisplayshortskip if the \useshortskip command was applied."

\let \NCC@ignorepar=\relax should fix the problem.

L.J.R.
  • 10,932