8

I have defined an environment for consistently typesetting a pair of alternative assumptions being made. The idea is that wherever I make an assumption, the assumptions are indented and on the left will be one possible assumption and on the right another, different assumption. So I have a way of showing: at this point, we either assume x or y. If we assume x, then abc, if we assume y, then def.

I defined the environment in the following way:

\newcommand{\assuming}[1]{\begin{center}\itshape[#1]\end{center}}
\newenvironment{altassumption}{\begin{center}%
    \begin{tabular}{*{2}{p{0.44\textwidth}}}}%
    {\end{tabular}\end{center}}

This works well enough, although perhaps I could tweak the output a bit, I'll see. I encountered a bit of a problem with the spacing above and below, however. Observe this MWE:

\documentclass[12pt]{article}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{setspace}
\doublespacing

\newcommand{\assuming}[1]{\begin{center}\itshape[#1]\end{center}}
\newenvironment{altassumption}{\begin{center}%
    \begin{tabular}{*{2}{p{0.44\textwidth}}}}%
    {\end{tabular}\end{center}}

\begin{document}

Lorem ipsum dolor sit amet, consectetuer

\begin{altassumption}

  \assuming{adipiscing elit. Aenean commodo}

  Aenean massa. Cum sociis natoque penatibus et magnis dis

  ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu,
  &
  \assuming{massa quis enim. Donec pede justo,}

  fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo,
  rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis
  eu pede mollis pretium. Integer

\end{altassumption}

tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean
vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat
vitae, eleifend ac, enim.

\begin{altassumption}

  laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel
  augue. Curabitur ullamcorper ultricies nisi.
  &
  rhoncus. Maecenas tempus,

\end{altassumption}

tellus eget condimentum rhoncus, sem quam semper libero, sit amet
adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus
pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt
tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis
ante. Etiam sit amet orci

\end{document}

enter image description here

Unfortunately, I've had to use double spacing, because I want to be able to write all over and annotate printed versions of the document.

You can see that the vertical spacing around the first pair of assumptions is very different to that around the second.

As you can see, if we add a few more words to our first assumption, the space below the environment is actually free to be filled up, creating different spacing above the environment to that below.

Lorem ipsum dolor sit amet, consectetuer

\begin{altassumption}

  \assuming{adipiscing elit. Aenean commodo}

  Aenean massa. Cum sociis natoque penatibus et magnis dis

  ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu,
  pretium quis, sem. Nulla consequat  
  &
  \assuming{massa quis enim. Donec pede justo,}

  fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo,
  rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis
  eu pede mollis pretium. Integer

\end{altassumption}

tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean
vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat
vitae, eleifend ac, enim.

enter image description here

Clearly, then, this depends on the precise length of the content and clearly I have taken the wrong approach to this environment. Can anyone suggest a fix or an altogether better approach?

13
  • I'd be inclined to use something like pdfparcolumns for this sort of thing. The setspace package will likely produce some surprising spacing around environments if you aren't careful or in some edge cases (but since this spaced out version is for editing, aesthetics seem rather beside the point).
    – jon
    Apr 29, 2016 at 1:28
  • @cfr Honestly, I don't know. I'm slightly ashamed to admit I've been using LaTeX for years, but \usepackage[parfill]{parskip} is a fossilised part of my preamble I've never really questioned! I used it because I want a blank line between paragraphs and no indentation of new paragraphs. A long time ago I must have learned that was the way to do it, and I've honestly never noticed any problems with spacing around tables generally or anything like that
    – Au101
    Apr 29, 2016 at 3:02
  • Hmmm... maybe it doesn't do that. I'll delete my comment.
    – cfr
    Apr 29, 2016 at 12:20
  • (Pedantic remark.) In case you are interested in knowing what happened with your code, the extra space you are complaining about comes from the \par (empty line) that you have after “Integer”, which causes an extra line to be added to the (implicit) \parbox. This essentially happens because you are nesting a center environment within another, which isn’t allowed for a reason (interference between \@setpar and \@restorepar) that cannot be explained in 600 characters. If you are interested in the details, I can post an answer (when I have time to… :-) .
    – GuM
    Apr 30, 2016 at 0:14
  • 1
    To the OP and to @cfr: In the end, I decided to post a new, independent question on this \@restorepar affair. The new question cites this one.
    – GuM
    May 1, 2016 at 3:39

1 Answer 1

4

How about something like this? This uses minipages as the tabular doesn't really seem appropriate here. The environment altassumption becomes a command \altassumption{}{} which takes 2 arguments.

\documentclass[12pt]{article}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{setspace,array}
\doublespacing
\newcommand{\assuming}[1]{\begin{center}\itshape [#1]\end{center}}
\newcommand\altassumption[2]{%
  \begingroup
  \centering
  \begin{minipage}[t]{.44\textwidth}
    #1
  \end{minipage}\hskip .04\textwidth
  \begin{minipage}[t]{.44\textwidth}
    #2
  \end{minipage}%
  \vskip 2\parskip\par\endgroup}
\begin{document}

Lorem ipsum dolor sit amet, consectetuer

\altassumption{%
  \assuming{adipiscing elit. Aenean commodo}
  Aenean massa. Cum sociis natoque penatibus et magnis dis

  ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu,
}{%
  \assuming{massa quis enim. Donec pede justo,}
  fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo,
  rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis
  eu pede mollis pretium. Integer
}

tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean
vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat
vitae, eleifend ac, enim.

\altassumption{%
  laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel
  augue. Curabitur ullamcorper ultricies nisi.
}{%
  rhoncus. Maecenas tempus,
}

tellus eget condimentum rhoncus, sem quam semper libero, sit amet
adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus
pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt
tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis
ante. Etiam sit amet orci

\end{document}

minipage alternative

8
  • Hey cfr, thanks for this it looks much better :) The [...] around the assumption "header", if you like (the thing being assumed) were intentional, but I have to admit, I wrote this code a while ago and noticed the problem with it more recently, and when I first looked at it, I thought I'd made that very mistake, too! :P
    – Au101
    Apr 29, 2016 at 17:04
  • Oh, I see. Hmm.... It looked odd to me in the output, too. I guess I'd be inclined to try to find a more obvious way of flagging the assumption. (That is, a way I'd expect to be obvious to me in a week or a year!)
    – cfr
    Apr 29, 2016 at 20:45
  • The real thing has, e.g. [Assuming he guesses ...]. The idea is this is actually a script. I wanted the assumptions bracketed off because I don't actually read them out - but I needed some kind of unassuming signpost to myself and I didn't want it too hidden away, e.g. in a footnote. Without the brackets I felt it looked too much like a header. In any case, it's obvious to me in the printed form, but when I 1st glanced back at the abstract definition \newcommand{\assuming}[1]{\begin{center}\itshape[#1]\end{center}} my immediate thought was Silly Au101, \itshape does not take arguments :P
    – Au101
    Apr 29, 2016 at 21:01
  • Why not write \newcommand{\assuming}[1]{\begin{center}\itshape [#1]\end{center}}? This is unambiguous.
    – cfr
    Apr 29, 2016 at 21:05
  • I've changed my answer accordingly....
    – cfr
    Apr 29, 2016 at 21:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .