1

This is a follow-up to Drawing a background grid based on linespread value. In a two-column document, the background lines are drawn in the first column only. Is there a way to show them in both columns?

Here is a short document for testing:

% compile with lualatex or xelatex:
\documentclass[twocolumn]{book}
\usepackage{fontspec,lipsum,microtype}
\setmainfont[Contextuals=Alternate]{EB Garamond}
\linespread{1.0609}
\AtBeginDocument{\setlength{\parindent}{1em}}
\setlength{\topskip}{\baselineskip}
\usepackage[centering,columnsep=1.5em,heightrounded]{geometry}
% grid from tex.stackexchange.com/a/150621:
\usepackage{atbegshi,picture,xcolor}
\AtBeginShipout{%
  \AtBeginShipoutUpperLeft{%
    \color{red}%
    \put(\dimexpr 1in+\oddsidemargin,
    -\dimexpr 1in+\topmargin+\headheight+\headsep+\topskip)%
    {%
      \vtop to\dimexpr\vsize+\baselineskip{
        \hrule
        \leaders\vbox to\baselineskip{\hrule width\hsize\vfill}\vfill
      }%
    }%
  }%
}
\begin{document}
\raggedbottom
\lipsum[1-8]
\end{document}

1 Answer 1

1

Here is a hack that seems to work:

enter image description here

Notes:

  • The hack is the magic number 4.1in that was guessed at. This should really be computed based on the column widths and the column separation.

Code:

\documentclass[twocolumn]{book}
\usepackage{lipsum}
\linespread{1.0609}
\AtBeginDocument{\setlength{\parindent}{1em}}
\setlength{\topskip}{\baselineskip}
\usepackage[centering,columnsep=1.5em,heightrounded]{geometry}
% grid from tex.stackexchange.com/a/150621:
\usepackage{atbegshi,picture,xcolor}
\AtBeginShipout{%
  \AtBeginShipoutUpperLeft{%
    \color{red}%
    \put(\dimexpr 1in+\oddsidemargin,
    -\dimexpr 1in+\topmargin+\headheight+\headsep+\topskip)%
    {%
      \vtop to\dimexpr\vsize+\baselineskip{
        \hrule
        \leaders\vbox to\baselineskip{\hrule width\hsize\vfill}\vfill
      }%
    }%
    \color{blue}%
    \put(\dimexpr 4.1in+\oddsidemargin,
    -\dimexpr 1in+\topmargin+\headheight+\headsep+\topskip)%
    {%
      \vtop to\dimexpr\vsize+\baselineskip{
        \hrule
        \leaders\vbox to\baselineskip{\hrule width\hsize\vfill}\vfill
      }%
    }%
  }%
}
\begin{document}
\raggedbottom
\lipsum[1-9]
\end{document}
2
  • Thank you! I’ll wait a little while before accepting this, in case another interesting solution appears, but this one does seem to do the trick.
    – Thérèse
    Commented Feb 6, 2014 at 23:57
  • @Thérèse: No problem. Like, I said it was just a hack and seemed to work. Am hoping a more detailed (and flexible) answer will show up so I can delete this one. Commented Feb 7, 2014 at 1:56

You must log in to answer this question.

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