2

So I'm trying to add a table to the header of my document. Basically I'm trying to match the style created in MS Word originally.

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand\headrule{}

\lhead{     
\begin{tabularx}{\textwidth}{|X r|} 
\hline\\    
Title: Title Here & Process Instruction\\
\hline  
\end{tabularx}  
}

Output has a right bar that is half of the left bar:

enter image description here

I can't figure out why it's doing this.

5
  • 1
    Welcome to TeX.SX! \hline & should do
    – user31729
    Commented Jun 4, 2015 at 12:36
  • 2
    remove the \\ after \hline (and add a % after \lhead{ and \end{tabularx} ) Commented Jun 4, 2015 at 12:36
  • 2
    @ChristianHupfer you need to practice your markdown:-) Commented Jun 4, 2015 at 12:36
  • Lol I've been fighting this for a while now too. Commented Jun 4, 2015 at 12:40
  • @DavidCarlisle: Those damned \\ characters
    – user31729
    Commented Jun 4, 2015 at 12:41

1 Answer 1

2

There's a & missing after \hline if some some explicit empty line is wanted, if no such line is requested, just remove \\ after \hline

\documentclass{article}


\usepackage{tabularx}
\usepackage{fancyhdr}
\usepackage{blindtext}
\pagestyle{fancy}
\renewcommand\headrule{}


\lhead{%     
\begin{tabularx}{\textwidth}{|X r|} 
\hline 
& \\    
Title: Title Here & Process Instruction\\
\hline  
\end{tabularx}%  
}

\pagestyle{fancy}

\begin{document}
\blindtext[20]

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .