网格排版

网格排版

问题

有什么方法可以管理文本停留在 tikzpicture 给出的网格上?

截屏

在此处输入图片描述

平均能量损失

\documentclass{article}

\usepackage{tikz}

\usepackage{eso-pic}

\AddToShipoutPicture{%
  \begin{tikzpicture}[remember picture, overlay]

  \tikzset{normal lines/.style={black!20, very thin}} 
  \tikzset{margin lines/.style={black!20, thick}} 

  \node at (current page.south west){
    \begin{tikzpicture}[remember picture, overlay]

      \draw[style=normal lines,step=0.5cm] (0,0) grid +(210mm,297mm); 
    \end{tikzpicture}
  };
  \end{tikzpicture}
}

\usepackage{blindtext}

\begin{document}

\section{Lorem ipsum}
\blindtext[2]

\section{Lorem ipsum}
\blindtext[3]

\section{Lorem ipsum}
\blindtext[2]

\end{document}

答案1

让它适用于所有输入并不是一件简单的事情,因为 TeX 确实想要使用弹性胶水来对齐事物,而这总是会让你偏离网格,但基本上你只需要确保添加的任何空格都是网格单位的倍数(我在这里取了 0.5 厘米)所以在这种情况下,我强制 baselineskip、topskip 以及节标题前后的空格适合这个网格

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usepackage{eso-pic}
\AddToShipoutPicture{%
  \begin{tikzpicture}
    [
      remember picture, 
      overlay,
      normal lines/.style={black!20, very thin},
    ]
    \draw [style=normal lines, step=0.5cm]  (current page.south west) grid (current page.north east); 
  \end{tikzpicture}%
}
\usepackage{blindtext}
\makeatletter
\renewcommand\section{\@startsection {section}{1}{\z@}%
  {-1cm}%
  {1cm}%
  {\normalfont\Large\baselineskip.5cm\relax\bfseries}}
\makeatother
\raggedbottom

\begin{document}

\lineskip0pt
\baselineskip.5cm
\normalbaselineskip=\baselineskip
\topskip\baselineskip

\section{Lorem ipsum}
\blindtext[2]

\section{Lorem ipsum}
\blindtext[3]

\section{Lorem ipsum}
\blindtext[2]

\end{document}

相关内容