12

I'm trying to create some custom graph paper for myself. However, I don't want page numbers on it, so I was wondering how to completely remove page numbers. My code is

\documentclass{scrartcl}
\usepackage[margin=25mm]{geometry}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{background}

\SetBgContents%
{   \begin{tikzpicture}[remember picture, overlay]
    \draw [line width=0.3pt,color=gray,step=0.5cm] (current page.south west) grid (current page.north east);
    \end{tikzpicture}
}
\SetBgScale{1}
\SetBgAngle{0}

\begin{document}

\begin{tikzpicture}
    \draw (0,0) rectangle (5,5);
\end{tikzpicture}

\end{document}

(The rectangle is just to have something on the page.)

Thanks!

Edit: I found the solution on my own and posted it as an answer. I am open to better solutions.

2
  • 4
    Any reason you can't use \pagestyle{empty} in the preamble? Works for me Commented Aug 12, 2016 at 20:01
  • @Au101, I actually found that solution just now and posted it as an answer. Thanks, though! Commented Aug 12, 2016 at 20:02

1 Answer 1

9

I found this answer (of course) 5 minutes after I posted this question, even though I'd spent a while looking for it. =)

I added the line \thispagestyle{empty}

for the code

\documentclass{scrartcl}
\usepackage[margin=25mm]{geometry}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{background}

\SetBgContents%
{   \begin{tikzpicture}[remember picture, overlay]
    \draw [line width=0.3pt,color=gray,step=0.5cm] (current page.south west) grid (current page.north east);
    \end{tikzpicture}
}
\SetBgScale{1}
\SetBgAngle{0}

\begin{document}
\thispagestyle{empty}

\begin{tikzpicture}
    \draw (0,0) rectangle (5,5);
\end{tikzpicture}

\end{document}

Which worked perfectly.

As Au101 mentioned in the comments, it is probably preferable to move \thispagestyle to the preamble:

\documentclass{scrartcl}
\usepackage[margin=25mm]{geometry}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{background}

\SetBgContents%
{   \begin{tikzpicture}[remember picture, overlay]
    \draw [line width=0.3pt,color=gray,step=0.5cm] (current page.south west) grid (current page.north east);
    \end{tikzpicture}
}
\SetBgScale{1}
\SetBgAngle{0}

\thispagestyle{empty}

\begin{document}

\begin{tikzpicture}
    \draw (0,0) rectangle (5,5);
\end{tikzpicture}

\end{document}

And then put the line in the main body of the document for any special cases where you want the page numbers again.

4
  • 1
    Again, I'd set it globally in the preamble, and then use \thispagestyle to adjust as needs be in the document. Doesn't sound like you'd need to do much adjusting in this document, but as a general rule, set the default page style for your documents in the preamble Commented Aug 12, 2016 at 20:06
  • @Au101, okay, thank you; I did so. If you post that as an answer, I will accept it. Commented Aug 12, 2016 at 20:07
  • Hey, don't worry about it, your answer is close enough that I'd just edit it as a second option and get yourself "self-learner" Commented Aug 12, 2016 at 20:25
  • @Au101, okay; thanks for your help! Commented Aug 12, 2016 at 20:26

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.