Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using a picture environment to \put some tikzpictures at places within the page from within \setkomavar{firsthead}. When I declare some pgf layers like so:

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background, main, foreground}

the pictures disappear. The reason for the layers is to create a fancy table environment to display some data. When I remove the layers, the pictures reappear. Does anyone know anything obvious to make the tikzpictures reappear? If not I'll make a minimal working example to explain what I mean. I've tried to do \begin{pgfonlayer}{main}...\end{pgfonlayer} but that doesn't change anything.

Edit: minimal working example

\documentclass{scrlttr2}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{tabularx}
\usepackage{color}

\usetikzlibrary{calc, fit, shadows, arrows, positioning}
% if these lines are commented out, the box draws.
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background, main, foreground}
% end comment out these lines

\newsavebox{\monotablecontent}
\newenvironment{monotable}[1]{%
  \begin{lrbox}{\monotablecontent}%
  \begin{tabular}{#1}}%
  %
  {%
  \end{tabular}
  \end{lrbox}
  \begin{tikzpicture}
    \node [inner xsep=0pt] (tbl){\usebox{\monotablecontent}};
    % table
    \draw[rounded corners=1pt,top color=gray!1,bottom color=gray!30,draw=black]
    (tbl.north east) rectangle (tbl.south west);
    % top line
    \draw[rounded corners=1pt,top color=gray!10!black,bottom color=gray!50!black,draw=black]
    ($(tbl.north west)$) rectangle ($(tbl.north east)-(0, 1.5\baselineskip)$);
    % bottom rule
    \draw[rounded corners=0.25pt,fill=gray,draw=black]
    (tbl.south west) rectangle ($(tbl.south east)+(0, 0.05)$);
  \end{tikzpicture}
}

\definecolor{myblue}{rgb}{0, 0.58, 0.85}

\newcommand*\invhead[1]{\sffamily{\color{myblue}\footnotesize{\textbf{#1}}}}
\newcommand*\head[1]{\tiny \invhead{#1}}

% set details
\setkomavar{fromname}{ACME Widgets}
\setkomavar{fromaddress}{1 Infinite Loop\\Sometown, 90210\\Uganda}
\setkomavar{fromphone}{+61 9876 5432}
\setkomavar{fromemail}{accounts@acme.com}
\setkomavar{fromfax}{+61 9876 5431}
\setkomavar{fromurl}{http://acme.com/}
\setkomavar{signature}{ACME Widgets}
\setkomavar{fromlogo}{}
\setkomavar{invoice}[Invoice number]{1234 567}
\setkomavar{date}{}
\setkomavar{customer}[Account number]{123456}

% set up a style for our boxes that we will eventually draw.
\tikzstyle{shadedbox} = [
  draw=black,
  shade,
  top color=white,
  bottom color=bottom,
  drop shadow={
    top color=black,
    bottom color=black,
    shadow xshift=2pt,
    shadow yshift=-2pt,
  },
  thin,
  rectangle,
  inner sep=2pt,
  inner ysep=2pt,
  outer ysep=1ex,
]

\newcommand*\monobox[2]{%
  \begin{tikzpicture}
    \definecolor{top}{RGB}{250,250,250}
    \definecolor{bottom}{RGB}{235,235,235}
    \begin{pfgonlayer}{main}
    \node [shadedbox, minimum width=0.18\textwidth, text width=0.18\textwidth, align=right] (box) {
      \begin{tabular}{r}
        \invhead{\scriptsize #1}\\
        \footnotesize{#2}\\
      \end{tabular}
    };
    \end{pgfonlayer}
  \end{tikzpicture}
}

% set the logo, draw some boxes...
\setkomavar{firsthead}{
  \usekomavar{fromlogo}\\
  \begin{picture}(0,0)
    \put(0,0){
      \parbox[t]{\textwidth}{
        \vspace{\useplength{toaddrvpos}}
        \vspace{3\baselineskip}
        \hspace{-2pt}
        \monobox{Last Bill}{\$29.95}
      }
    }
  \end{picture}
}

\begin{document}

\begin{letter}[backaddress=false]{%
    Mr Joe Customer\\%
    17 Unicorn Avenue\\
    Narwhtropilis\\%
    Uganda\\%
}

\setkomavar{subject}{Invoice}
\opening{Dear Joe Customer,}
Here is your invoice.
\closing{Regards}
\end{letter}
\end{document}

The errors I seem to get are:

! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ main 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ main 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ main 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ main 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ main 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ main 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ main 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ main 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ main 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ main 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ main 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ main 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ main 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ main 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ main 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ main 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ main 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ main 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ main 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ main 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ main 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ main 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ main 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ main 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ main 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! A <box> was supposed to be here.
<to be read again> 
                   =
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerboxsaved@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ main 
l.114 \opening{Dear Joe Customer,}

? 
! Missing number, treated as zero.
<to be read again> 
                   \pgf@layerbox@ foreground 
l.114 \opening{Dear Joe Customer,}

? 
Foot of first page
Address (addressee)
Location field: empty
Reference line(s): with fields but without date
Title: no
Subject: before opening
[1] (./test.aux)


 )
Output written on test.pdf (1 page).
share|improve this question
1  
I think it would be a good idea to post a minimal example. It will definitely make it easier to find and test solutions. –  Jake Nov 8 '11 at 8:40
1  
No worries, I just thought it could be something extremely obvious to someone more experienced in TeX :). I'll work up an example. –  slurms Nov 8 '11 at 8:42
    
Where do you declare the layers? This needs to be done before the picture, best in the preamble. –  Martin Scharrer Nov 8 '11 at 9:19
1  
You have pfgonlayer instead of pgfonlayer. Although from the errors it seems that you only have this mistake in the MWE here. If you then remove the spaces from \pgfsetlayers like so: \pgfsetlayers{background,main,foreground} it should compile without errors. –  Roelof Spijker Nov 8 '11 at 9:31
1  
Note that wh1t3's other comment is also relevant: you can't have spaces in the \pgfsetlayers command. –  Loop Space Nov 8 '11 at 11:02
show 4 more comments

2 Answers

up vote 9 down vote accepted

After fixing the problems highlighted in wh1t3's comment, there is still one that remains. The answer comes from Section 82.3 of the PGF manual (Using Layers):

Note: You can not add anything to the main layer using this environment. The only way to add anything to the main layer is to give graphic commands outside all {pgfonlayer} environments.

The main layer is not treated in the same way as the other layers. The layering system works by putting the commands for each layer into boxes and then placing those boxes in the right order. It's possible to not put stuff in boxes and everything that isn't in a box goes on the main layer. So the lay-out mechanism is:

  1. Process all the boxes listed before main in the order given.
  2. Process all non-boxed stuff.
  3. Process all the boxes listed after main in the order given.

When you use \begin{pgfonlayer}{main} then it looks for a box in which to put the stuff. For some unknown reason, it does actually put the stuff in a box (it really ought to flash a big neon sign saying "You're trying to put stuff on the main layer using pgfonlayer. DO NOT DO THIS.") but then that box gets shoved in the corner like last year's Christmas decorations and never looked at again.

So have another go but be sure not to use the main layer explicitly. If you still encounter problems, either edit the question to explain what those are or ask a new question.

share|improve this answer
    
That's exactly it, I removed \begin{pgfonlayer}{main} and it all seems to be working again. D'oh! –  slurms Nov 8 '11 at 10:39
add comment

Actually, the problem is having erroneous spaces in the pgfsetlayers command. Replace

\pgfsetlayers{background, main, foreground}

with

\pgfsetlayers{background,main,foreground}

and all should be fine!

share|improve this answer
add comment

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.