在两列中显示基线

在两列中显示基线

这是根据线扩展值绘制背景网格。在双列文档中,背景线只在第一列绘制。有没有办法让它们在两列中都显示?

以下是一个用于测试的简短文档:

% 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

这里有一个黑客这似乎有效:

在此处输入图片描述

笔记:

  • 黑客4.1in是猜测的神奇数字。这实际上应该根据列宽和列间距来计算。

代码:

\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}

相关内容