9

How to balance lines in two-column document that contains figures? In other words - how to set the vertical margins of figure with caption so that the line after the figure corresponds to the line in the next (right or left) column?

In a two-column document I typeset dictionary entries, including photos placed either bellow the entry or at the top of the page (max 1 photo per column). In case in each column of the page there is a figure (placed right under the entry), the lines in two columns corresponds. In case there are two photos (one of them placed at the top), the lines do not correspond. In case there is a photo only in one column, the lines do not correspond. Even in case in each column there is a figure placed on top, the lines do not correspond.

MWE:

\documentclass[8pt,c5paper,twocolumn]{extbook}
\usepackage[paper=c5paper, top=1.5cm, headsep=0.4cm, bottom=1.5cm, left=1cm, right=1cm]{geometry}
\usepackage{fancyhdr}
\usepackage[icelandic, latin, czech]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tgpagella}
\usepackage[scaled=0.90]{helvet} % ss
\usepackage{enumitem}
\usepackage{hanging}

% example text and images
\usepackage{lipsum}
\usepackage{mwe}
\usepackage{color}
% float control
% Alter some LaTeX defaults for better treatment of figures:
% See p.105 of "TeX Unbound" for suggested values. 
% See pp. 199-200 of Lamport's "LaTeX" book for details.
%   General parameters, for ALL pages:
\renewcommand{\topfraction}{0.9}    % max fraction of floats at top
\renewcommand{\bottomfraction}{0.8} % max fraction of floats at bottom
%   Parameters for TEXT pages (not float pages):
\setcounter{topnumber}{1}
\setcounter{bottomnumber}{1}
\setcounter{totalnumber}{1}     % 2 may work better
\setcounter{dbltopnumber}{2}    % for 2-column pages
\renewcommand{\dbltopfraction}{0.9} % fit big float above 2-col. text
\renewcommand{\textfraction}{0.07}  % allow minimal text w. figs
%   Parameters for FLOAT pages (not text pages):
\renewcommand{\floatpagefraction}{0.7}  % require fuller float pages
% N.B.: floatpagefraction MUST be less than topfraction !!
\renewcommand{\dblfloatpagefraction}{0.7}   % require fuller float pages
% remember to use [htp] or [htpb] for placement

\makeatletter
\setlength{\@fptop}{0pt}
\setlength{\@fpbot}{0pt plus 1fil}
\makeatother


%COMMANDS
\newcommand\entry[3][]{\hangpara{1em}{1}{\fontfamily{phv}\selectfont{\textbf{{#2}}}}\ 
    #3\ifx\relax#1\relax\markboth{#2}{#2}\else\markboth{#1}{#1}\fi
    \par}\nopagebreak[4]


%FANCY PAGE STYLES
\pagestyle{fancy}

% DICTIONARY PAGE STYLE
\fancypagestyle{dictstyle}{%
\renewcommand{\headrulewidth}{0.4pt}
  \fancyhf{}
  \fancyhead[LE,LO]{{\fontfamily{phv}\selectfont{\textbf{\rightmark}}}}
  \fancyhead[CO,CE]{\thepage}%the page numbers will be printed when the dictionary is ready
  \fancyhead[RE,RO]{{\fontfamily{phv}\selectfont{\textbf{\leftmark}}}}}

\begin{document}
\twocolumn
\pagestyle{dictstyle}
% the letters in alphabetical order


\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}
\begin{figure}[ht]
    \centering
    \setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}\fbox{\includegraphics[width=5.5cm]{example-image-b}}
    \caption{Vöðuselur}
    \end{figure}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}
\begin{figure}[ht]
    \centering
    \setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}\fbox{\includegraphics[width=5.5cm]{example-image-b}}
    \caption{Vöðuselur}
    \end{figure}}    

    \entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}
\begin{figure}[ht]
    \centering
    \setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}\fbox{\includegraphics[width=5.5cm]{example-image-b}}
    \caption{Vöðuselur}
    \end{figure}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}
\begin{figure}[ht]
    \centering
    \setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}\fbox{\includegraphics[width=5.5cm]{example-image-b}}
    \caption{Vöðuselur}
    \end{figure}} 

    \entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}
\begin{figure}[ht]
    \centering
    \setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}\fbox{\includegraphics[width=5.5cm]{example-image-b}}
    \caption{Vöðuselur}
    \end{figure}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}
\begin{figure}[ht]
    \centering
    \setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}\fbox{\includegraphics[width=5.5cm]{example-image-b}}
    \caption{Vöðuselur}
    \end{figure}} 

    \entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\begin{figure}[ht]
    \centering
    \setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}\fbox{\includegraphics[width=5.5cm]{example-image-b}}
    \caption{Vöðuselur}
    \end{figure}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
    \entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}
\begin{figure}[ht]
    \centering
    \setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}\fbox{\includegraphics[width=5.5cm]{example-image-b}}
    \caption{Vöðuselur}
    \end{figure}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}
\begin{figure}[ht]
    \centering
    \setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}\fbox{\includegraphics[width=5.5cm]{example-image-b}}
    \caption{Vöðuselur}
    \end{figure}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}
\begin{figure}[ht]
    \centering
    \setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}\fbox{\includegraphics[width=5.5cm]{example-image-b}}
    \caption{Vöðuselur}
    \end{figure}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}}
\entry[VS]{{Example entry} }{{\color{blue}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ example word}}}\foreignlanguage{czech}{{ \lipsum[23]}}
\begin{figure}[ht]
    \centering
    \setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}\fbox{\includegraphics[width=5.5cm]{example-image-b}}
    \caption{Vöðuselur}
    \end{figure}}
\clearpage

\end{document}

The command to make an dictionary entry:

\newcommand\entry[3][]{\hangpara{1em}{1}{\fontfamily{phv}\selectfont{\textbf{{#2}}}}\ 
#3\ifx\relax#1\relax\markboth{#2}{#2}\else\markboth{#1}{#1}\fi
\par}\nopagebreak[4]

An example entry:

\entry[VS]{{VS} }{{\color{darkgreen}{\small{\textbf{  zkr}}}}{\foreignlanguage{icelandic}{\textbf{ vatnssalerni}}}\foreignlanguage{czech}{{ WC, záchodky}}}

Example photo placement.

\begin{figure}[ht]
\centering
\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}\fbox{\includegraphics[width=5.5cm]{ds_image_voduselur_0_2.jpg}}
\caption{Vöðuselur}
\end{figure} 

Updated (MWE aboved does not show properly the undesired behaviour)

Real MWE using sample images and real entries can be downloaded.

1
  • I have changed the title of the question so that it is easier to understand the point of the question.
    – chejnik
    Jul 15 '15 at 3:48
1
+100

[expunged original answer]

Ok. Your new MWE shows another level of difficulty and a promise of future complications.

What you need is a full-fledged two column baseline grid.

I think your best bets are grid, gridset and ConTeXt.

8
  • This is very helpful answer, I will test these suggestions for sure. I would still prefer to use all images of the same dimention.
    – chejnik
    Jul 18 '15 at 15:35
  • It seems to be a really complex issue. First of all the \raggedbottom that makes one column shorter than other, does not look good. The fact is that even without figures the lines are not in balance, probably because of \parskip as you have suggested. The ideal situation is - a) each page has the same amount of lines (obviously if there is a figure, less but first line aligned to left/right column line), b) the entries does not behave like paragraphs (if I change \par to \\ in entry command, the figures cannot be placed). Moreover some lines consist only from \footnotesize text
    – chejnik
    Jul 18 '15 at 18:02
  • In the meantime I defined a cleaner command to align the figures to text lines. I am updating the answer right now, give me a couple of minutes. Jul 18 '15 at 18:14
  • 1
    Done. About your last comment: can you provide an example that compiles giving bad alignment? The MWE we have now looks ok to me. Jul 18 '15 at 18:21
  • 1
    Thanks, but it kinda missed the point; you need a much more general framework to handle titles and different font sizes. I just defined a command to crudely quantize the height of figures. In any case, for future reference, it's still accessible in the edit history for anyone to see. (BTW, your dictionary is looking very good!) Jul 19 '15 at 13:14

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.