first question in this stack community. I'm trying to create a new style for title page:


\usepackage[paper=a4paper, top=4cm, bottom=2.5cm, left=2.0cm, right=2cm]{geometry}



    urlcolor= green,
    linkcolor = black,






  \makebox[\textwidth][c]{\includegraphics[width = \textwidth]{Logo.jpg}}




    {\Huge Sample Report\\}



    {\LARGE  Italy \\}

    {\large  23 May 2019 \\}

\fancyhead[R]{Sample Report}
\fancyfoot[R]{Page \thepage~of \pageref{LastPage}} % start page counting



The pdf file renders fine but I get an error in my IDE (pasted below) corresponding to the \end{adjustbox} - not sure how I can fix this?

! Package graphics Error: Division by 0.See the graphics package documentation for explanation.Type H for immediate help.... \end{adjustbox}

Here's what I want the page to look like (blanked out areas - title, name, header etc. had confidential identifying information so had to be removed):

enter image description here

  • Welcome to tex.sx. – barbara beeton Jul 15 '19 at 18:55
  • @Gautam \makebox[\textwidth][c]{...} is useless given the \includegraphics[width = \textwidth]{...} and the contents of the tikzpicture environment is not valid TikZ syntax. If you replace the whole \begin{tikzpicture} ... \end{tikzpicture} with \includegraphics[width=\textwidth]{example-image}, the compilation works (but then, the \begin{adjustbox}{width=\paperwidth} ... \end{adjustbox} seems to be a convoluted way to do something that could probably be done with simply \includegraphics). Also, please use example-image instead of Logo.jpg: it's always available. – frougon Jul 15 '19 at 19:15
  • @Gautam Maybe what you want is \makebox[0pt]{\includegraphics[width=\paperwidth]{example-image}}\par at the beginning of the center environment. – frougon Jul 15 '19 at 19:22
  • @frougon thanks! It works - I don't get any errors anymore. However, the image that I was using on my title page doesn't span the entire page anymore (it did previously). I tried using \begin{tikzpicture} with \paperwidth but that didn't work either - I have a small amount of empty space left on the left margin now. – Gautam Jul 15 '19 at 19:23
  • @frougon using \makebox in the \begin{center} loop places the image in the body of the document whereas I want it in the header only. – Gautam Jul 15 '19 at 19:25

The code:

\makebox[\textwidth][c]{\includegraphics[width = \textwidth]{Logo.jpg}}

that you put inside the tikzpicture doesn't conform to any TikZ syntax (it would be valid inside a node command, but the \makebox[\textwidth][c]{...} is useless anyway, since you are already passing width=\textwidth to \includegraphics). Thus, TikZ doesn't recognize it and, being a very forgiving parser, simply ignores it. As a consequence, the resulting tikzpicture has zero width. Then you put this tikzpicture inside \begin{adjustbox}{width=\paperwidth} ... \end{adjustbox}. This is what triggers the division by 0, when adjustbox divides \paperwidth by the width of the tikzpicture (0pt) in order to compute the scale factor.

The following code will produce the desired layout:

\begin{tikzpicture}[remember picture, overlay]
  \node[inner sep=0, anchor=north] at (current page.north)

for instance after your \thispagestyle{fancy} (but you may want to put \thispagestyle{empty} for the first page instead, if this is the only thing you wanted in the header there). The scaling preserves the aspect ratio of the image. Here is a full, self-contained example:



\begin{tikzpicture}[remember picture, overlay]
  \node[inner sep=0, anchor=north] at (current page.north)


Because of the remember picture option, you need to compile the document twice.

enter image description here

Other errors in your code

Concerning the other error message that is printed with your code, namely:

pdfTeX warning (ext4): destination with the same identifier (name{page.1}) has been already used, duplicate ignored

it is explained here. In short, you can solve it by putting for instance \pagenumbering{Alph} before \begin{titlepage} and \pagenumbering{arabic} after \end{titlepage}.

Also, this kind of thing is incorrect:

{\Huge Sample Report\\}

You can use either:

{\Huge Sample Report\par}


{\Huge Sample Report\\[2\baselineskip]
other text in Huge size}

(the latter only if there is text immediately following, as in this example).

| improve this answer | |
  • Thanks! This works too - I seem to lose the horizontal \headrule but I'm guessing that's been covered by the image file - I am okay with that. I do want some text in the page (need to stick with the official template) namely the document title, author name and date. Is there a way to add a 'footer' as well? perhaps by using another tikzpicture but anchored south at current page.south? – Gautam Jul 15 '19 at 19:55
  • Yes, or \fancyfoot, depending on the positioning requirements. With the current page TikZ node, you can easily place stuff flush against the page edges. Headers and footers (fancyhdr) are not that close to the edges, unless you define layout parameters very specially. They are more suited for run-in headings and page numbers. I've explained how to fix another error in your code, please look at the updated answer. – frougon Jul 15 '19 at 20:00
  • @Gautam I explained why you got the division by zero, proposed a solution that apparently achieves the layout you wanted and fixed several other unrelated errors in your code. Is there any reason why you didn't upvote nor accept my answer? Please consult “How do you accept an answer?” in case you don't know what this means, thanks. – frougon Jul 16 '19 at 8:12
  • Thanks! I was trying it out until now - it works. – Gautam Jul 16 '19 at 15:21

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.