# Using {tabu} to make thick table lines in header generates errors

I want to place a thick vertical line next to my page number in the header of every page. I have chosen to build a small table and add the line to it. It works fine, until I add the option (part of the {tabu} package) of defining the thickness of the table border. The code (that generates many errors) looks like this:

\documentclass{book}

\usepackage{fancyhdr}
\usepackage{tabu}
\begin{document}
\pagestyle{fancy}
\fancyfoot{}
~
\newpage
~
\end{document}


when I put the table in the main text (i.e. not in the header) they come out fine

\begin{tabu}{|[2pt]c}\bfseries\thepage \\ ~ \end{tabu}


when I remove the [2pt] line there is no problem either. Nevertheless, I can't make out from the generated errors what went wrong. For instance, the first error reads:

!missing number, treated as zero


When I compile this as part of my larger project, the compilation process crashes entirely!

My questions would be: Why is this code not working inside of headers and how should it be changed to obtain the desired effect?

-

Unfortunately the tabu package is often incompatible with latex (most notably in its unfortunate decisions to change the > syntax, here it is tripping over active characters.

\documentclass{book}

\usepackage{fancyhdr}
\usepackage{tabu}

\pagestyle{fancy}
\fancyfoot{}
\makeatletter
\makeatother
\begin{document}
~
\newpage
~
\end{document}

-
Many thanks, this indeed works splendidly! Do I understand correctly that the code you have added finds and suppresses the use of any active characters by the {tabu} package? –  skleijn Apr 10 '13 at 11:37
@skleijn the description you give makes it sound like a rather grander project than it was:-): better to say it is a workaround that locally disables some code in the standard output routine to avoid the particular error that your example showed. all \@activechar@info does is make a warning that active characters are being used in an unsafe place, but the warning itself messes up tabu's processing of the array preamble so I silence the warning. –  David Carlisle Apr 10 '13 at 11:47

You're using a sledgehammer. Better measurement can be obtained by using rules and doing carefully the alignment.

Here's a possibility (the showframe option and the geometry package are used just for the example):

\documentclass{book}

%% the following two packages are just for the example
\usepackage[pass,showframe]{geometry}
\usepackage{lipsum}
%%

\usepackage{calc}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}

\newcommand{\digitheight}{\fontcharht\font0 }
\newcommand{\rightpage}{\mypagenumber{\ }{l}{\ \ \bfseries\thepage}}
\newcommand{\leftpage}{\mypagenumber{\bfseries\thepage\ \ }{r}{\ }}
% Arguments of \mypagenumber:
% #1: tokens to be set at the left of the bar
% #2: position of the bar (use l for the right header, r for the left)
% #3: tokens to be set at the right of the bar
\newcommand{\mypagenumber}[3]{%
\raisebox{\ht\strutbox-\digitheight}{%
\makebox[0pt][#2]{%
\bfseries
#1%
\vrule depth \dimexpr 24pt - \digitheight\relax width 2pt
#3}%
}%
}

\begin{document}

\lipsum[1-12]
\end{document}
`

-