[Tex/LaTex] sig-alternate class, and twocolumn unbalanced bottom alignment problem

acmformattingtwo-columnvertical alignment

EDIT: turns out the below is not really a requirement for ACM – but still a good Latex exercise, I reckon 🙂

I have bumped into a problem with the Alternate ACM LaTeX2e Style File V2.4 (APRIL 2009 CLS) class file, and for the first time, I get a minimal example that demonstrates the issue which is simpler than my original problem 🙂

Here, I can demonstrate the issue simply by using the lipsum package; the example test.tex file is this:

% convert -density 200x200 "test.pdf[1]" test_pg2_.png
% crop: 0x1536 to bottom; then paint 0x458 size 1700x206

\documentclass{sig-alternate}

\setlength{\pdfpagewidth}{8.5in}
\setlength{\pdfpageheight}{11in}

\usepackage{lipsum}




\begin{document}


\title{De finibus bonorum et malorum}
\numberofauthors{1} %
\author{
\alignauthor
Dr. Reinhardt Donnerkebab
\email{rd@rd.com}
}

\maketitle

\begin{abstract}
\lipsum[1]
\end{abstract}



\section{Praesent}

% we're on first page
% ¶.7 goes one paragraph into second page
% NOTE: the below line is changed to show effect:
\lipsum[1-10]



\section{Vivamus}

\lipsum[21-30]


\end{document}

So, if I use the emphasized line as is, \lipsum[1-10], which generates 10 paragraphs, the bottom of page 2 (of 3) is:

test_pg2of3_1-10.png
that is, bottom row in left column is lower than bottom row in right column.

If I instead use \lipsum[1-17], to generate 17 paragraphs, the bottom of page 2 (of 3) is:

test_pg2of3_1-17.png
that is, bottom row in right column is lower than bottom row in left column.

Finally, is I use \lipsum[1-27], to generate 27 paragraphs, the bottom of page 2 (of 4) is:

tezs_pg2of4_1-27.png
that is, bottom rows of both columns are finally balanced – but they are on the same level as the 'higher' rows in the previous examples!

(the red surface is added in GIMP, it is positioned the same in respect to bottom of page)

 

So, how do I persuade this class file to give me consistent, aligned (balanced) rows at the bottom of the page? NOTE: This is (I guess) slightly different from TeX Frequently Asked Questions — question label "balance": Balancing columns at the end of a document, as this is about balancing columns in the "middle" of the document.

Thanks in advance for any answers,
Cheers!

 

EDIT: Thanks to the help in Expanding (edef) a lipsum command? and Debugging – any packages that will draw individual line (and word) frame boxes?, I believe now I have a clearer example (code below) and a question:

sigdebug.png

One can notice, that as long as the first section heading doesn't kick in, text rows/lines on both left and right column are aligned. As soon as the section heading is typeset (here on left column), the lines are shifted vertically and the left column doesn't match the right one (right side after mismatch emphasized in green; this coloring done in GIMP).

So I guess, the question is more exactly – how do I insert some sort of a vertical length/glue/strut(?) so that section heading is typeset in such a way, that the first next line "snaps" vertically to the position of the matching line in the other column?

Code here:

\documentclass{sig-alternate}

\setlength{\pdfpagewidth}{8.5in}
\setlength{\pdfpageheight}{11in}

% \usepackage{afterpage}
\usepackage[nopar]{lipsum} % MUST be nopar here!
\usepackage[normalem]{ulem} % for \uline underline

% https://tex.stackexchange.com/questions/26806/expanding-edef-a-lipsum-command
\makeatletter
\def\unpacklipsum#1#2#3{%
  \count@=#1\relax
  \advance\count@\m@ne
  \def#3{}%
  \loop\ifnum\count@<#2\relax
    \advance\count@\@ne
    \edef#3{#3\csname lipsum@\romannumeral\count@\endcsname}%
  \repeat}
\makeatother

% https://tex.stackexchange.com/questions/26803/debugging-any-packages-that-will-draw-individual-line-and-word-frame-boxes
\makeatletter
% from syst-ext.mkii
\long\def\ConvertToConstant#1#2#3%
  {\edef\@@stringa{\expandafter\detokenize\expandafter{#2}}%
   \edef\@@stringb{\expandafter\detokenize\expandafter{#3}}%
   #1{\@@stringa}{\@@stringb}}

% from core-fnt.mkii
\def\doprocesswords#1 #2\od
  {\ConvertToConstant\doifnot{#1}{}
     {\processword{#1} %
      % expandafter added
      \expandafter\doprocesswords#2 \od}}

% from core-fnt.mkii
\def\processwords#1%
  {\doprocesswords#1 \od\unskip}

% from syst-gen.mkii
\long\def\doifnot#1#2%
  {\let\donottest\dontprocesstest
   \edef\@@stringa{#1}%
   \edef\@@stringb{#2}%
   \let\donottest\doprocesstest
   \ifx\@@stringa\@@stringb
     \expandafter\gobbleoneargument
   \else
     \expandafter\firstofoneargument
   \fi}

\long\def\gobbleoneargument#1{}
\long\def\firstofoneargument#1{#1}

\makeatother

% -----

\renewcommand{\fboxsep}{1pt}%
\let\processword\uline %\fbox



\begin{document}


\title{De finibus bonorum et malorum}
\numberofauthors{1} %
\author{
\alignauthor
Dr. Reinhardt Donnerkebab
\email{rd@rd.com}
}

\maketitle

% if below part is before \maketitle;
% it will insert a blank first page:
\let\unexpanded\protected
\input{norm-tex.mkii} % upon \showmakeup - \normalvfil required
\input{supp-vis.mkiv}
\showmakeup



\begin{abstract}
\lipsum[1]
\end{abstract}



\section{Praesent}

% we're on first page
% ¶.7 goes one paragraph into second page
% \lipsum[1-7]

% \uline{\lipsum[1-10]} % cannot

\unpacklipsum{1}{1}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{2}{2}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{3}{3}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{4}{4}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{5}{5}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{6}{6}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{7}{7}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{8}{8}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{9}{9}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{10}{10}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}



\section{Vivamus}

% \lipsum[21-30]

\unpacklipsum{21}{21}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{22}{22}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{23}{23}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{24}{24}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{25}{25}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{26}{26}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{27}{27}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{28}{28}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\unpacklipsum{29}{29}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}

\end{document}

Best Answer

Well, I think I have some sort of a solution now. Basically, since the spacing between rows/lines in Latex is apparently controlled by \baselineskip, one essentially has to ensure that a section heading takes up a vertical space, which is integer multiple of \baselineskip (i.e., it is quantized :)).

That would mean (I guess) is, either letting Latex typeset the section heading, and then trying to figure out the remaining height to add as vertical space, which seemed kind of tedious - or wrapping everything (related to the section heading) in a box with specified height, and letting Latex take care of the rest.

From the approaches I tried, the easiest (see code comments) seems to use a \parbox preceeded by a \noindent (or \parindent = 0pt), with a specified height; in the question, the image shows the section heading (by default) takes a little more than three line heights - so the \parbox here is specified to be 3\baselineskip; the code shows simply the replacement that needs to be done around \section

...
%%% \@startsection {NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}
% parbox seemingly inserts parindent, even for a section; \noindent fails if inside \parbox; but works if first (and in group!) & matches OK int\baseline
% minipage kills beforeskip/afterskip of section
% vbox seems ok, but then needs to be less than int\baseline skip to match OK
{\noindent%
  \parbox[t][3\baselineskip]{\linewidth}{
  % \begin{minipage}[t][3\baselineskip]{\linewidth}
  % \vbox to 3\baselineskip{
  \section{Vivamus}
  % }
  % \end{minipage}
  }%
}
% \lipsum[21-30]
...

... which results with following PDF rendering:

sigdebug-noipar3.png

... and correspondingly, since subsequent rows/lines match now - also the bottom rows between the two columns are aligned.

In any case, if there is a different solution, I'd love to hear it ...
Cheers!

 

Coupla useful links:

Related Question