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?

Au101
  • 10,278
  • 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 '16 at 01: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 '16 at 03:02
  • Hmmm... maybe it doesn't do that. I'll delete my comment. – cfr Apr 29 '16 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 '16 at 00:14
  • @GustavoMezzetti I'd be very interested in that kind of additional info if you're willing to post it – Au101 Apr 30 '16 at 00:17
  • OK, but, please, not now: it’s a pretty long story. If somebody else would volunteer, I’ll make no question of priority… ;-) – GuM Apr 30 '16 at 00:19
  • @GustavoMezzetti Of course, this question isn't going anywhere and cfr has offered an actual solution, so there's no urgency from me, it's simply a case of the more you know :) – Au101 Apr 30 '16 at 00:22
  • @GustavoMezzetti This is (sort of) why I switched one of the center environments in devising an alternative i.e. I have center within a minipage but not another center and the outer centring is done with \centering (although I think it could be done with center in this case, but it would complicate the spacing). But I don't really understand it. I can just look at it and think 'I probably wouldn't try that, but this...'. – cfr Apr 30 '16 at 00:31
  • @cfr’s comment about minipage made me reflect, and now I see that I had overthought: the extra line would occur as a consequence of the extra \par even whithout the nested center environment, because the p column specifier calls \@arrayparboxrestore, thus reactivating \par (that tabular turns off). But the issue about nested center environments remains: the \@setpar called by \@trivlist also changes \@par, thus defeating the \@restorepar inserted by \@endparenv (via \@doendpe) in the temporary redefinition of \par. Is this a LaTeX bug? – GuM Apr 30 '16 at 01:19
  • @GustavoMezzetti But shouldn't it be safe to use center within a minipage? – cfr Apr 30 '16 at 01:29
  • @cfr: That’s the point I’m trying to clarify to myself too: the minipage environment does not restore the default definition of \@par (\let\par\@@par\par); should it? That is, should it preserve a “long-term change” to \par made outside of itself, or not? But I think this is not the right hour (in Europe) to discuss this sort of things… Let’s continue tomorrow. – GuM Apr 30 '16 at 01:44
  • @GustavoMezzetti Seconded. – cfr Apr 30 '16 at 01:47
  • 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 01 '16 at 03:39

1 Answers1

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

cfr
  • 198,882
  • 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 '16 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 '16 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 '16 at 21:01
  • Why not write \newcommand{\assuming}[1]{\begin{center}\itshape [#1]\end{center}}? This is unambiguous. – cfr Apr 29 '16 at 21:05
  • I've changed my answer accordingly.... – cfr Apr 29 '16 at 21:07
  • Fair point that, thanks for everything, i'm sure you'll get the tick, but i'll wait a bit first. also forgot to UV, so +1 – Au101 Apr 29 '16 at 21:17
  • I noticed with this answer that the spacing below the group is actually somewhat larger than the spacing above. I reasoned this must have something to do with \vskip 2\parskip\par and the double spacing of the document. So I looked up setspace and found that the \doublespacing command uses for 12pt documents, \setstretch {1.655}%. So I modified your original command to ... \vskip 1.655\parskip\par\endgroup} which seems to work better, would you say that would be a worthwhile modification? I didn't take the most scientific approach to checking the output ... :P – Au101 Apr 29 '16 at 22:58
  • I really just used 2 because \parskip was obviously not enough. But your approach seems far more scientific than mine! Note that I'm not sure exactly what impact the parfill option to parskip has here. It also depends on what you are trying to match. The reason setspace does that is because that is the factor which will result in line spacing of 2. This is because the default spacing is not 1 else the top of one line of text would touch the bottom of the line before (say if you had X under y or something. Here, center adds vertical space before and after, for example. – cfr Apr 30 '16 at 00:26