TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was attempting to create a bounding box across an entire page (as I've seen here in beamerinnerthemetexsx.sty). However, the box will not flush with the left margin.

As can be seen in this example, setting the margin to 0 works for any text in the document. However the bounding box is not flush with the left margin (it's 15pt off). This both will not allow me to draw in that region, and results in an "Overfull \hbox" error, as the bounding box is trying to span from 15pt right of the left margin to 15pt beyond the edge of the page.

\documentclass{article}
\usepackage{tikz}
\usepackage{geometry}
\geometry{
 papersize={254mm,190.5mm},
 margin = 0mm
 }

\begin{document}
  \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
    \draw [->] (0,0) to (10mm,10mm);
    \draw [gray] (0,0) rectangle (40mm,40mm); 
\end{tikzpicture}

\begin{flushleft}
Text will flush with the margins.
\end{flushleft}
\begin{flushright}
Unlike the bouding box.
\end{flushright}
\end{document}

Is there a way to fix this? Should I approaching this a different way entirely?

share|improve this question
1  
Set up the tikzpicture as an overlay. So pass the environment the following in its optional arguments, remember picture,overlay – A.Ellett Jan 28 at 17:15

That's the \indent. Add \noindent before your tikzpicture, this will disable the indent.

If you don't need the indent anywhere in the document, you can use \setlength{\parindent}{0pt} to your preamble, which will make it a global option. If you wanted to restore it after the tikzpicture, simply write \setlength{\parindent}{15pt} (that's the default length).

Also, there's a page node, so you can simply write your bounding box as

\useasboundingbox (current page.south west) rectangle (current page.north east);
share|improve this answer
    
Why not just suggest \noindent before the environment? – A.Ellett Jan 28 at 17:24
    
@A.Ellett Uhh, good point. I guess I had a different train of thought. I will fix the answer. – Alenanno Jan 28 at 17:25

I would recommend treating the picture as an overlay.

So you would start the environment as

\begin{tikzpicture}[remember picture,overlay]

Even with this, the tikzpicture will have its origin (0,0) at the point where the picture is defined. So, I would recommend using relative coordinates and redefining where you want your origin with respect to the page nodes that TikZ provides. So here's something that might work for you:

\documentclass{article}
\usepackage{tikz}
\usepackage{geometry}
\geometry{
 papersize={254mm,190.5mm},
 margin = 0mm
 }

\begin{document}

\noindent 
\begin{tikzpicture}[remember picture,overlay]

    \draw[line width=4pt,orange] (current page.south west) rectangle (current page.north east);

    \path (current page.north west) -- ++ (0mm,-40mm) coordinate (origin);
    \draw [->] (origin) to ++(10mm,10mm);
    \draw [gray] (origin) rectangle ++(40mm,40mm); 

\end{tikzpicture}%%
Hello (flush left) \hspace*{\fill} (flush right) Bye%%

\end{document}

which results in

enter image description here

Playing with where you place \noindent (such as immediately before Hello) will show you how the tikzpicture is being placed on the page.

If the tikzpicture is all that you're going to create with your document, you might want to consider using the standalone package.

\documentclass[border=2pt]{standalone}
%% I like a "border", but that's optional!
\usepackage{tikz}

\begin{document}

\noindent 
\begin{tikzpicture}

    \useasboundingbox (0,0) rectangle (254mm,190.5mm);
    \coordinate (origin) at (0,0);    

    \draw [->] (origin) to ++(10mm,10mm);
    \draw [gray] (origin) rectangle ++(40mm,40mm); 

\end{tikzpicture}%%

\end{document}

Notice how I did not make this an overlay in this case. The above code results in

enter image description here

If you have other content for your document, either of these approaches can work.

Assuming that you want no other content on the same page as the tikzpicture, in the first approach you will have to issue something like

\clearpage

after the environment. And by using an overlay, you can use a page geometry more nature for your exposition.

Working with the second approach, you'll want to do something with \includegraphics and \raisebox to place it appropriately on the page.

If you provided more information about what kind of content you want in the picture, then I could probably give you better feedback.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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