6

I'm writing a paper for a journal, which publishes in double column style, but the submitted manuscript has to be single-column. This means, I have to make sure that the formulas are properly formatted for both variants. The challenging thing here is, that in double column style the horizontal space is far smaller than in single column. So one possibility would be to manually break all formulas such that they fit the double column style. However, this has the disadvantage that they would look strangely formatted in the single column manuscript. What is the best practice to solve this?

I'm aware of the two packages breqn and autobreak, which however both do not work properly (to my knowledge). Loading breqn immediately breaks my whole document (build fails even if I do not use it anywhere). Loading autobreak works, but the "autobreak" environment creates errors.

What I basically want is an environment where I can put atomic parts of my equation into, which are then automatically arranged either in a single line or in multiple lines, depending on how much horizontal space is available, like I used the hypothetical chunk-environment here:

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
\begin{gather}
    \begin{chunk} % <--
    f\colon \mathbb R \to \mathbb R,
    \end{chunk}   % <--
    \begin{chunk} % <--
    f\left(x\right) = 2x
    \end{chunk}   % <--
\end{gather}
\end{document}

Depending on the amount of horizontal space available, I want this code to either produce

enter image description here

or

enter image description here

Does something like this exist? If not, what else are the best practices?

1
  • In a similar position I just made everything work for a two-column layout and the reviewers had to deal with tall narrow equations on the submitted version. Even reviewer 2 didn't complain about that
    – Chris H
    Apr 30, 2021 at 11:31

2 Answers 2

4

I doubt this has any hope of working in a general sense, but I was able to make it work in this limited example. In particular, one has to think how they would like something like aligned to work when the margin gets too small...I'm not sure an obvious answer presents itself. Nonetheless, I have provided an EDIT that may provide a first stab at handling it.

I created a breakable environment, which (in this example), I called inside of gather, which will be applying the equation label in the normal way. breakable creates a [b]-aligned minipage of \linewidth minus some delta to allow for the tag width. The delta is an optional argument to breakable. The environment sets up inline math in the minipage, centered, \onehalfspacing, sloppy, and in \displaystyle.

Content in the environment can be set in \chunk{} macros, which itself is set in an unbreakable box (an optional argument can set the math style). \allowbreak is called after setting the box, to allow for additional line-breakability.

For things that need to break within a portion of the full \linewidth, such as one side of a long align, I have tried to deal with that by way of the interbreakable environment, which has a similar argument syntax to breakable. However, here, the minipage is raggedright and top-aligned. Furthermore, the optional dimensional argument should account not just for the tag width, but also the width of the other portion of the line which is not part of the interbreakable environment (Therefore, it generally needs an increase beyond the default, see discussion at end).

In the MWE, I don't use \chunks inside of interbreakable, only because the terms are short enough to preclude a line break at a wrong spot. However, it should work, if needed (I think).

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage{amssymb,setspace,environ}
\newcommand\chunk[2][\displaystyle]{\sbox0{$#1#2$}\box0\allowbreak}
\newenvironment{breakable}[1][30pt]
{\begin{minipage}[b]{\dimexpr\linewidth-#1}\sloppy\centering
  \onehalfspacing$\displaystyle}
{$\end{minipage}}
\NewEnviron{interbreakable}[1][30pt]{
  \setbox2=\hbox{$\displaystyle\BODY$}%
  \ifdim\wd2 > \dimexpr\linewidth-#1\relax\wd2=\dimexpr\linewidth-#1\relax\fi
  \begin{minipage}[t]{\wd2}\sloppy\raggedright
  \onehalfspacing$\displaystyle\BODY$\end{minipage}}
%\textwidth=1.5in
\usepackage[showframe,pass]{geometry}
\begin{document}
Here is my first equation:
\begin{gather}
\begin{breakable}
    \chunk{f\colon \mathbb R \to \mathbb R,}\quad
    \chunk{f\left(x\right) = 2x}
\end{breakable}
\end{gather}
And now, for the even more complicated next equation,
\begin{gather}
\begin{breakable}
    \chunk{f\colon \mathbb R \to \mathbb R,}\quad
    \chunk{f\left(x\right) = 2x^2 + 3x,} \text{ and }
    \chunk{f'\left(0\right) = 0}
\end{breakable}
\end{gather}
Look, Mom!! I can do align after a fashion.
\begin{align}
  y &= \begin{interbreakable}[60pt]m_1x^3 + m_2x^2 
    + m_3x + b\end{interbreakable}\\
  E &= \begin{interbreakable}[60pt]mc^2 + \strut\log (ac) 
    - \int_0^1 x\,dx\end{interbreakable}
  \end{align}
\end{document}

enter image description here

With the smaller \textwidth uncommented:

enter image description here

To study the effect of the optional argument on interbreakable, the MWE uses 60pt in Eq 3. If I set it too small, let's say 40pt, the equation gets wider and crowds out the tag, which has to shift downward:

enter image description here

If I make it too big, let's say 80pt, then it makes the available space for the environment too narrow and breaks more often than needed:

enter image description here

4

You could do something like this which produces one of these two layouts depending on the line width. Note this is coded as a document level choice not a measurement on each expression.

enter image description here

enter image description here

\documentclass
[twocolumn]
{scrartcl}
\usepackage{amsmath}
\usepackage{amssymb}
\ifdim\linewidth<250pt
  \let\zaligned\aligned
  \let\endzaligned\endaligned
\else
   \def\zaligned{\,\let\\=\relax}
   \def\endzaligned{}
\fi

\begin{document}
\begin{gather}
\begin{zaligned}
    f\colon \mathbb R \to \mathbb R,\\
    f\left(x\right) = 2x
\end{zaligned}
\end{gather}
\end{document}
1
  • Any idea on how to change this code such that it produces a \qquad in the first case, where there is a line break in the second case?
    – theV0ID
    Apr 29, 2021 at 23:32

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.