2

The idea was to save the vertical position right after beginning the multi columns and then count from that position the next suitable position whenever there is need to align a text paragraph to a baseline grid row.

Problem is that after playing with the values (pt and sp) I somehow couldn't accomplish what I wanted. It doesn't seem to be enough to just adjust the gridrowheight length and other values (font size, linespacing and parskip) so that paragraphs on both sides would be fully aligned to the baseline grid; vertical spaces get added to certain positions, but their height is not precisely what they should be.

I think the problem has something to do with the position values. I feel like I'm missing something here, but at the moment I'm not sure what it is.

\documentclass[11pt]{article}
\usepackage{geometry}
\usepackage{parskip}
\usepackage{setspace}
\usepackage{intcalc}
\usepackage{zref-savepos}
\usepackage[colaction]{multicol}
\geometry{a4paper}
\geometry{portrait}
\geometry{top=2cm,right=2cm,bottom=2cm,left=2cm}

\setlength{\parindent}{1cm}
\setlength{\parskip}{0pt}

\newlength\textstartypos
\newlength\vspacedistance
%\newlength\tempval

\newcommand{\settextstartypos}[1]{
\zsavepos{#1}
\setlength\textstartypos{\the\dimexpr\zposy{#1}sp}
%\the\dimexpr\zposy{#1}sp
}

\newlength\gridrowheight
%\addtolength\gridrowheight{40pt}
\addtolength\gridrowheight{1706432sp}

\newcommand{\skiptonextypos}[1] {
\zsavepos{#1}
\setlength\vspacedistance{\textstartypos}
\addtolength\vspacedistance{-\the\dimexpr\zposy{#1}sp}
\setlength\vspacedistance{\intcalcMod{\vspacedistance}{\gridrowheight}sp}
%\setlength\tempval{\intcalcMod{\vspacedistance}{\gridrowheight}sp}
\setlength\vspacedistance{\intcalcSub{\gridrowheight}{\vspacedistance}sp}
\vspace{\vspacedistance}
}

\begin{document}
\begin{spacing}{1.0}
\begin{multicols}{2}
\settextstartypos{textstartypos}
\lipsum[2]

\skiptonextypos{someposition1}
\lipsum[3]

\lipsum[4]

\skiptonextypos{someposition2}
\lipsum[5]

\skiptonextypos{someposition3}
\lipsum[6]
\end{multicols}
\end{spacing}
\end{document}

not quite aligned

  • One problem is the "LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right." The positions are stored in the aux-file when the page is written. In the next run you are using this values to change the positions -- but this naturally change the positions again. So you never reach a stable state. – Ulrike Fischer Jul 19 '16 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.