21

I need to balance the heights of the last two columns of my ACM article that is typeset using sigplanconf.cls. This class file defines the following command:

\newcommand{\balancecolumns}{%
  \vfill\eject
  \global\@colht = \textheight
  \global\ht\@cclv = \textheight}

However, the above \balancecolumns command didn't work for me. I also tried the solutions proposed in response to similar questions: How to balance last page of two-column layout?, Uneven text distribution with two-column layout, and https://stackoverflow.com/q/2149854/130224. Specifically, I tried the flushend, balance, and multicol pacakges. But, none of these packages could automatically balance the last two columns of my bibliography section.

I managed to manually break the list of references using the command \vfill\eject. But, this solution required manipulating the generated bbl file. I'd prefer an automatic solution that doesn't require changing a generated file.

Note that, the bibliography section is the last section of the article, but it runs over two pages.

0

5 Answers 5

8

With the balance package the output is correct.

One must issue \balance between two paragraphs that fall in the first column of the final page. This might need to insert it manually in the .bbl file, if the last page consists only of bibliography items.

7
  • 2
    Thanks for the tip. I didn't try the \balance in the bbl file. Anyways, I'd rather not to modify the bbl file. So, I still wonder if there is a cleaner solution that doesn't require manipulating the bbl file. Dec 15, 2011 at 22:39
  • Assuming the etoolbox package is available, would \AtBeginEnvironment{thebibliography}{\balance} do the trick? Dec 16, 2011 at 0:53
  • 1
    @MikeRenfro No, looking at the documentation of balance: the \balance command should be put between two paragraphs in the first column of the last page.
    – egreg
    Dec 16, 2011 at 11:24
  • If the start of the bibliography wound up in that position, would it work? Or would a literal paragraph break need to be present? Dec 16, 2011 at 13:00
  • 1
    @ChristophThiede Here sigplanconf is discussed, not acmart.
    – egreg
    Sep 7, 2023 at 21:17
5
+50

Here's an approach that seems to work. Truth be told, I've only tried it in article.cls with twocolumn and by inputing a .bbl file directly:(See edit below for verification with sigplanconf.cls).

\documentclass[twocolumn]{article}
\usepackage{balance}
\usepackage{lastpage}

\makeatletter
    \def\balanceissued{unbalanced}%flag to indicate if \balance has been used
    \let\oldbibitem\bibitem
    \def\bibitem{%
        \ifnum\thepage=\lastpage@lastpage%
            \expandafter\ifx\expandafter\relax\balanceissued\relax\else%
                \balance%
                \gdef\balanceissued{\relax}\fi%
            \else\fi%
        \oldbibitem}
\makeatother
\begin{document}
    \input{addreading.bbl}
\end{document}

Based on @egreg's previous answer and the comments, it uses the balance package and inserts a \balance command on the last page by renewing the \bibitem command. The lastpage package is used to define \lastpage@lastpage. The \balanceissued is to prevent \balance from being called multiple times on the last page. Interestingly, it seems to work fine if this occurs (which could shorten the code a bit).

Here is without the above:

without balance

and with the above (run twice to establish the last page):

enter image description here

Edit:

Assuming I am interpreting the question correctly, I have verified that the approach works with sigplanconf. Below is a test article using blindtext and enough references to get onto the next page (as the question states). Is this what you are after?

\documentclass{sigplanconf}
\usepackage[pangram]{blindtext}
\usepackage{balance}
\usepackage{lastpage}

\makeatletter
    \def\balanceissued{unbalanced}%flag to indicate if \balance has been used
    \let\oldbibitem\bibitem
    \def\bibitem{%
        \ifnum\thepage=\lastpage@lastpage%
            \expandafter\ifx\expandafter\relax\balanceissued\relax\else%
                \balance%
                \gdef\balanceissued{\relax}\fi%
            \else\fi%
        \oldbibitem}
\makeatother
\begin{document}
\title{Using \texttt{\textbackslash{}balance} to equalize the last two columns of references in a \texttt{sigplanconf} conference paper}
\authorinfo{John Doe}{Bogus University}{[email protected]}
\toappear{To appear somewhere}
\maketitle
\begin{abstract}
\Blindtext[1][1]
\end{abstract}
\section{Introduction}
\Blindtext[3][1]
\section{Materials and Methods}
\Blindtext[4][1]
\section{Results and Discussion}
\Blindtext[4][1]
\section{Conclusions}
\Blindtext[1][1]

\begin{thebibliography}{100}
    \bibitem{Aguado06}
    Daniel Aguado, Tatiana Montoya, Jos{\'e} Ferrer, and Aurora Seco.
    \newblock Relating ions concentration variations to conductivity variations in
      a sequencing batch reactor operated for enhanced biological phosphorus
      removal.
    \newblock {\em Environmental Modelling \& Software}, 21(6):845--851, 2006.

    \bibitem{Ahn07}
    Johwan Ahn, Sarah Schroeder, Michael Beer, Simon McIlroy, Ronald~C. Bayly,
      John~W. May, George Vasiliadis, and Robert~J. Seviour.
    \newblock Ecology of the microbial community removing phosphate from wastewater
      under continuously aerobic conditions in a sequencing batch reactor.
    \newblock {\em Applied and Environmental Microbiology}, 73(7):2257--2270, 2007.

    \bibitem{Aiso05}
    T.~Aiso, H.~Yoshida, A.~Wada, and R.~Ohki.
    \newblock Modulation of {mRNA} stability participates in
      stationary-phase-specific expression of ribosome modulation factor.
    \newblock {\em Journal of Bacteriology}, 187(6):1951--1958, 2005.

    \bibitem{Aitken07}
    Michael~D. Aitken, Mark~D. Sobsey, Nicole~A. Van~Abel, Kimberly~E. Blauth,
      David~R. Singleton, Phillip~L. Crunk, Cora Nichols, Glenn~W. Walters, and
      Maria Schneider.
    \newblock Inactivation of \textit{Escherichia coli} {O157:H7} during
      thermophilic anaerobic digestion of manure from dairy cattle.
    \newblock {\em Water Research}, 41(8):1659--1666, 2007.

    \bibitem{Akiyama03}
    M.~Akiyama, T.~Tsuge, and Y.~Doi.
    \newblock Environmental life cycle comparison of polyhydroxyalkanoates produced
      from renewable carbon resources by bacterial fermentation.
    \newblock {\em Polymer Degradation and Stability}, 80(1):183--194, 2003.

    \bibitem{AlNajjar11}
    Muamar~M. Al-Najjar, Erik~R. Coats, and Frank~J. Loge.
    \newblock The role of the microbial stringent response in excess intracellular
      accumulation of phosphorous in mixed consortia fed synthetic wastewater.
    \newblock {\em Water Research}, 45(16):5038--5046, 2011.

    \bibitem{Alban03}
    A.~Alban, S.~O. David, L.~Bjorkesten, C.~Andersson, E.~Sloge, S.~Lewis, and
      I.~Currie.
    \newblock A novel experimental design for comparative two-dimensional gel
      analysis: Two-dimensional difference gel electrophoresis incorporating a
      pooled internal standard.
    \newblock {\em Proteomics}, 3(1):36--44, 2003.

    \bibitem{Albuquerque13}
    M.~G.~E. Albuquerque, G.~Carvalho, C.~Kragelund, A.~F. Silva, M.~T.~B. Crespo,
      M.~A.~M. Reis, and P.~H. Nielsen.
    \newblock Link between microbial composition and carbon substrate-uptake
      preferences in a {PHA}-storing community.
    \newblock {\em {ISME} Journal}, 7(1):1--12, 2013.

    \bibitem{Albuquerque10_CSTR}
    M.~G.~E. Albuquerque, S.~Concas, S.~Bengtsson, and M.~A.~M. Reis.
    \newblock Mixed culture polyhydroxyalkanoates production from sugar molasses:
      The use of a 2-stage {CSTR} system for culture selection.
    \newblock {\em Bioresource Technology}, 101(18):7112--7122, 2010.

    \bibitem{Albuquerque07}
    M.~G.~E. Albuquerque, M.~Eiroa, C.~Torres, B.~R. Nunes, and M.~A.~M. Reis.
    \newblock Strategies for the development of a side stream process for
      polyhydroxyalkanoate {(PHA)} production from sugar cane molasses.
    \newblock {\em Journal of Biotechnology}, 130(4):411--421, 2007.

    \bibitem{Albuquerque11}
    M.~G.~E. Albuquerque, V.~Martino, E.~Pollet, L.~Av{\'e}rous, and M.~A.~M. Reis.
    \newblock Mixed culture polyhydroxyalkanoate {(PHA)} production from volatile
      fatty acid {(VFA)}-rich streams: Effect of substrate composition and feeding
      regime on {PHA} productivity, composition and properties.
    \newblock {\em Journal of Biotechnology}, 151(1):66--76, 2011.

    \bibitem{Albuquerque10}
    M.~G.~E. Albuquerque, C.~A.~V. Torres, and M.~A.~M. Reis.
    \newblock Polyhydroxyalkanoate {(PHA)} production by a mixed microbial culture
      using sugar molasses: Effect of the influent substrate concentration on
      culture selection.
    \newblock {\em Water Research}, 44(11):3419--3433, 2010.

    \bibitem{Alleman80}
    James~E. Alleman and Robert~L. Irvine.
    \newblock Storage-induced denitrification using sequencing batch reactor
      operation.
    \newblock {\em Water Research}, 14(10):1483--1488, 1980.

    \bibitem{Andreottola97}
    G.~Andreottola, G.~Bortone, and A.~Tilche.
    \newblock Experimental validation of a simulation and design model for nitrogen
      removal in sequencing batch reactors.
    \newblock {\em Water Science and Technology}, 35(1):113--120, 1997.

    \bibitem{Anterrieu14}
    Simon Anterrieu, Luca Quadri, Bert Geurkink, Inez Dinkla, Simon Bengtsson,
      Monica Arcos-Hernandez, Tomas Alexandersson, Fernando Morgan-Sagastume, Anton
      Karlsson, Markus Hjort, Lamija Karabegovic, Per Magnusson, Peter Johansson,
      Magnus Christensson, and Alan Werker.
    \newblock Integration of biopolymer production with process water treatment at
      a sugar factory.
    \newblock {\em New Biotechnology}, 31(4):308--323, 2014.

    \bibitem{Appel15}
    Felicity~J. Appel.
    \newblock Advancing a post-anoxic biological nutrient removal process selecting
      for nitritation.
    \newblock Master's thesis, University of Idaho, 2015.

    \bibitem{Appels08}
    Lise Appels, Jan Baeyens, Jan Degr{\`e}ve, and Raf Dewil.
    \newblock Principles and potential of the anaerobic digestion of
      waste-activated sludge.
    \newblock {\em Progress in Energy and Combustion Science}, 34(6):755--781,
      2008.

    \bibitem{ArcosHernandez12}
    M.~V. Arcos-Hernandez, B.~Laycock, S.~Pratt, B.~C. Donose, M.~A.~L. Nikolic,
      P.~Luckman, A.~Werker, and P.~A. Lant.
    \newblock Biodegradation in a soil environment of activated sludge derived
      polyhydroxyalkanoate {(PHBV)}.
    \newblock {\em Polymer Degradation and Stability}, 97(11):2301--2312, 2012.

    \bibitem{ArcosHernandez13}
    M{\'o}nica~V. Arcos-Hern{\'a}ndez, Bronwyn Laycock, Bogdan~C. Donose, Steven
      Pratt, Peter Halley, Salah Al-Luaibi, Alan Werker, and Paul~A. Lant.
    \newblock Physicochemical and mechanical properties of mixed culture
      polyhydroxyalkanoate {(PHBV)}.
    \newblock {\em European Polymer Journal}, 49(4, SI):904--913, 2013.

    \bibitem{ArcosHernandez12_Dissertation}
    M{\'o}nica~Vanessa Arcos~Hern{\'a}ndez.
    \newblock {\em Production and Characterization of Mixed Culture
      Polyhydroxyalkanoates}.
    \newblock Doctoral thesis, The University of Queensland, 2012.

    \bibitem{ArdernLockett14}
    Edward Ardern and William~T. Lockett.
    \newblock Experiments on the oxidation of sewage without the aid of filters.
    \newblock {\em Journal of the Society of Chemical Industry}, 33(10):523--539,
      1914.

    \bibitem{Arora85}
    Madan~L. Arora, Edwin~F. Barth, and Margaret~B. Umphres.
    \newblock Technology evaluation of sequencing batch reactors.
    \newblock {\em Journal Water Pollution Control Federation}, 57(8):867--875,
      1985.

    \bibitem{Artan02}
    N.~Artan, D.~Orhon, and R.~Tasli.
    \newblock Design of {SBR} systems for nutrient removal from wastewaters subject
      to seasonal fluctuations.
    \newblock {\em Water Science and Technology}, 46(8):91--98, 2002.

    \end{thebibliography}
\end{document}

Second to last page: secondtolast page

Last page balanced with \balance automatically inserted: balanced last page

7
  • 1
    Thanks for the detailed answer. I am actually using this with IEEEtrans which is not the same class as in the original question. And your solution works without problem. I gave you the bounty but OP should come back after four years and accept your solution :)
    – Aydin
    Oct 16, 2015 at 13:56
  • 4
    This doesn't work with the new ACM template, there is an import clash with the lastpage package. Sep 15, 2017 at 14:25
  • @guho Seems very cool. It doesn't seem to work for me using documentclass[english,final,twocolumn]{article}, \usepackage[big]{dgruyter}. Aug 14, 2019 at 22:16
  • 1
    It doesn't work with current acmart for several reasons. \theTotPages expands to \arabic{TotPages} which is not acceptable to \ifnum. If you change this to \ifnum\value{TotPages}=\value{page} then you're actually comparing numbers, but then you hit the second problem: \value{TotPages} is always the wrong number! What you actually need is the value of the label TotPages, which will be typeset by \ref{TotPages}, but I don't know how to use that in any kind of \if expression.
    – zwol
    Oct 20, 2020 at 3:02
  • 1
    @MicahSmith I just posted an answer that works with current versions of acmart. Hope it's not too late to do you any good.
    – zwol
    Jan 26, 2021 at 18:42
3

Solution based on @zwol's answer:

\newcounter{BalanceAtReference}
\setcounter{BalanceAtReference}{35}
\newcounter{ReferenceIndexForBalancing}

\makeatletter

% Disable acmart's automatic invocation of \balance from \AtEndDocument,
% which is usually too late.
\global\@ACM@balancefalse

% Invoke command when the \bibitem reaches the specified value
\def\@balancelastpageonce{%
  \ifnum\value{ReferenceIndexForBalancing}=\value{BalanceAtReference}
    \newpage
  \else
    \relax
  \fi
  \stepcounter{ReferenceIndexForBalancing}
}
\pretocmd{\bibitem}{\@balancelastpageonce}
  {} % on success
  {\@latex@error{Patching \bibitem failed}{\@ehd}}

\makeatother

This code inserts a \newpage after 35th reference. You need to manually find where to break and replace the 35 in \setcounter{BalanceAtReference}{35} for your case.

I'm using \documentclass[sigconf,screen]{acmart} on Overleaf. For some reason \balance does not work for me, even when manually inserting \balance to the bbl file, but \newpage works.

1
  • This is the only solution I could get working for acmart template, thank you!
    – K.S.
    Feb 24, 2022 at 21:57
0

Here is an approach for automatically issuing \balance at an appropriate point in the bibliography, that is compatible with the totpages package, as used by e.g. current versions of acmart.cls. It uses \getrefnumber, which is defined in the refcount package, and \pretocmd, which is in etoolbox; acmart.cls already loads both of these.

\makeatletter

% Disable acmart's automatic invocation of \balance from \AtEndDocument,
% which is usually too late.
\global\@ACM@balancefalse

% Invoke \balance from the first \bibitem on the last page of the document.
\newif\if@balanceissued\@balanceissuedfalse
\def\@balancelastpageonce{%
  \if@balanceissued
    \relax
  \else
    \ifnum\getrefnumber{TotPages}=\value{page}%
      \balance
      \@balanceissuedtrue
    \fi
  \fi
}
\pretocmd{\bibitem}{\@balancelastpageonce}
  {} % on success
  {\@latex@error{Patching \bibitem failed}{\@ehd}}

\makeatother

Prepending the additional code to \bibitem seems to be more reliable than appending it -- I tried it both ways and got weird low-level errors with \apptocmd.

However, this does not always actually make the columns balance -- see discussion in the comments. I will revise this answer if I come up with something that works more reliably.

4
  • Thanks for picking this up, and your seems like a very reasonable approach. Adding this to my document, I don't see any differences. (My last page of references, which is the final page in my doc, is still not balanced.) How would I debug that this is working as intended? I'm now on acmart 1.67 fwiw. Will also try to create a MRE. Jan 27, 2021 at 15:09
  • I am actually having the same problem with the document I wanted this for, and I don't have any idea how to debug it. :-( It seems to be sensitive to exactly how many bibliography entries are on the last page, but beyond that, no clue.
    – zwol
    Jan 27, 2021 at 15:16
  • I was able to create a smaller example where your solution does work as intended, but in this example just putting \balance before \bibliography{references.bib} also successfully balances. Jan 27, 2021 at 15:39
  • Not able to quickly come up with a MRE for my paper, but let us know if you make any updates! Jan 27, 2021 at 15:45
-1

I was compiling a document in IEEEtran conference style, which generates two columns. The document ends with a bibliography using IEEEbib style.

The flushend package would always take one citation from the middle of the bibliography and put it in the left (wrong) column, whereas the rest of the bibliography was in the right column. Using the keeplastbox option made no difference.

But the balance package works perfectly. I put the \balance command just above the short Acknowledgements section, which precedes the command to generate the bibliography.

You must log in to answer this question.

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