2

I am building on my resume on latex and need fine grid lines to compare spacing between sections and subsections. You might need this info.

\documentclass{article}
\usepackage[a4paper,bottom = 0.6in,left = 0.56in,right = 0.56in,top = 0.6in]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{array}
\usepackage{booktabs}
\usepackage{enumitem}
\usepackage{wrapfig}
\usepackage{microtype}
\usepackage{titlesec}
\usepackage{textcomp}
\usepackage[colorlinks=false]{hyperref}
\usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{verbatim}
\newcommand{\xfilll}[2][1ex]{
\dimen0=#2\advance\dimen0 by #1
\leaders\hrule height \dimen0 depth -#1\hfill}
\titleformat{\section}{\large\scshape\raggedright}{}{0em}{}
\renewcommand\labelitemi{\raisebox{0.4ex}{\tiny$\bullet$}}
\renewcommand{\labelitemii}{$\cdot$}
\pagenumbering{gobble}
% \usepackage[normalem]{ulem}  % for underline
% \usepackage{sectsty}
% \sectionfont{\centering}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcommand{\sbt}{\,\begin{picture}(-1,1)(-1,-3)\circle*{2.5}\end{picture}\ }
3

Welcome to TeX.SE! If I understood your question correctly, you would like to draw a grid in front of, or behind the normal document contents.

Ready-made grid with eso-pic

Drawing a ready-made grid in the foreground or background is easy to do with the eso-pic package:

\documentclass{article}
\usepackage{xcolor}
\usepackage[grid, gridunit=mm, gridcolor=blue!40, subgridcolor=blue!20]{eso-pic}
\usepackage{lipsum}

\begin{document}

\lipsum

\end{document}

page 1


page 2

The units available for the gridunit option are mm, in, bp and pt. You can additionally pass the gridBG option to eso-pic if you want it to draw the grid in the background.

Manual grid with TikZ

TikZ provides simple and powerful tools to do this kind of thing too. Using TikZ requires a little more work, but provides much greater control over the output than one has with eso-pic. Several methods are possible; here, we'll use the grid operation in conjunction with the current page node (see The Grid Operation and Referencing the Current Page Node – Absolute Positioning in the TikZ and PGF manual, § 14.8 and § 17.13.2 of the manual for version 3.1.4a).

Following the request you made in a comment, here is an example with a rather fine grid (step=0.5pt) that will be laid in the background of the first page only—actually, wherever you decide to put the tikzpicture:

\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}

\begin{document}
\begin{tikzpicture}[remember picture, overlay,
                    help lines/.append style={line width=0.05pt}]
  \draw[help lines] (current page.south west) grid[step=0.5pt]
                    (current page.north east);
\end{tikzpicture}%
\lipsum
\end{document}

Zoom on the beginning of the first paragraph:

Small part of first paragraph

With the following code, the same grid will be colored in light blue and laid in the background of all pages:

\documentclass{article}
\usepackage{tikz}
\usepackage{eso-pic}
\usepackage{lipsum}

\AddToShipoutPictureBG{%
\begin{tikzpicture}[remember picture, overlay,
                    help lines/.append style={line width=0.05pt,
                                              color=blue!10}]
  \draw[help lines] (current page.south west) grid[step=0.5pt]
                    (current page.north east);
\end{tikzpicture}%
}

\begin{document}
\lipsum
\end{document}

Small part of first paragraph

Of course, it is possible to draw two grids on top of each other:

\documentclass{article}
\usepackage{tikz}
\usepackage{eso-pic}
\usepackage{lipsum}

\AddToShipoutPictureBG{%
\begin{tikzpicture}[remember picture, overlay,
                    help lines/.append style={line width=0.05pt,
                                              color=blue!10},
                    major divisions/.style={help lines,line width=0.1pt,
                                            color=red!20} ]
  \draw[help lines] (current page.south west) grid[step=0.5pt]
                    (current page.north east);
  \draw[major divisions] (current page.south west) grid[step=5pt]
                         (current page.north east);
\end{tikzpicture}%
}

\begin{document}
\lipsum
\end{document}

Small part of first paragraph

Pointer to a related question

Note: you can find several complex answers based on TikZ or other techniques in How can I make a perfect page grid that fits my page for measuring purposes in TikZ?.

| improve this answer | |
  • Thanks, your answer helped me a lot. I want the grid to be a more fine but using pt is not enough. Can you help me with that? – Anurag Gupta Jul 26 '19 at 18:36
  • Please see the latest edit of my answer. – frougon Jul 26 '19 at 19:42

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.