# Drawing a background grid based on \linespread value

I’m trying to help a friend set an Arabic book in LaTeX and I’m facing this very same uneven line spacing issue (except that the book is completely in Arabic).

Now I’m trying to find the \linespread setting that is just big enough to ensure even line spacing but not any bigger, so I thought drawing a grid and visually examining the lines with different setting to find the desired ones.

But, I do not even understand what, say, 1.5 in \linespread{1.5} actually mean (I read many discussions and answers but I still don’t get it), so I need help in:

• Setting a background grid (horizontal lines are enough).
• Make the spacing between grid lines follow \linespread setting i.e. they should represent the ideal line spacing if TeX didn’t do its vertical glue magic.

(I tried grid option of eso-pic but couldn’t wrap my head around the meaning of its options to get what I described above).

This should do what you want. A box consisting of the requested number of lines, drawn at the baselines, is added with \AtBeginShipout.

\documentclass{article}
\usepackage{atbegshi,picture,xcolor}
\AtBeginShipout{%
\AtBeginShipoutUpperLeft{%
\color{red}%
\put(\dimexpr 1in+\oddsidemargin,
{%
\vtop to\dimexpr\vsize+\baselineskip{
\hrule
}%
}%
}%
}

\usepackage{kantlipsum}

\begin{document}
\kant
\end{document}


What does \linespread{1.5} do? Every time LaTeX does a setting of \baselineskip, it will multiply the normal value by that factor. For instance, if the normal baselineskip is 12pt, it will become 18pt; for \small, when the normal value is 11pt, it will become 16.5pt. However, \topskip is not modified.

• Thanks, it does not seems not to play nice with bidi when the document is set to RTL (i.e. \usepackage[rldocument]{bidi}) generating some warnings and the grid is displaced, but I can live with that. Dec 19 '13 at 6:43
• @egreg It's a helpful post, would you please help hint me how to put 3 line grid for each text line? one on top, one on middle and another one on bottom. Mar 14 '18 at 18:01

With package bidi-atbegshi, this even becomes much easier (you only have to change \AtBeginShipoutUpperLeft in @egreg's code to \AtBeginShipoutUpperRight:

\documentclass{article}
\usepackage{bidi-atbegshi,picture,xcolor}
\usepackage[RTLdocument]{bidi}
\AtBeginShipout{%
\AtBeginShipoutUpperRight{%
{\color{red}%
\put(\dimexpr 1in+\oddsidemargin,
{%
\vtop to\dimexpr\vsize+\baselineskip{
\hrule
}%
}%
}%
}%
}

\usepackage{kantlipsum}

\begin{document}
\kant
\end{document}


With a little change to @egreg's code, this works fine in RTL too:

\documentclass{article}
\usepackage{atbegshi,picture,xcolor}
\usepackage[RTLdocument]{bidi}
\AtBeginShipout{%
\AtBeginShipoutUpperLeft{%
{\color{red}%
\put(\dimexpr -1in-\oddsidemargin,
{%
\vtop to\dimexpr\vsize+\baselineskip{
\hrule
}%
}%
}}%
}