I am pretty new to TeX and right now I am facing a challenge in creating double-framed table in header of my document. Intended goal is in image: Table intended in header of my document. Text is only dumy.

Combining answer here:

Create Double line Border in table

with some googling I found this code:

\documentclass [a4paper, 12pt, twoside] {article}               
\usepackage [czech] {babel}                         
\usepackage [utf8] {inputenc}                           
\usepackage [left=2.5cm, right=2cm, headheight=110pt, top = 6.5cm, bottom=3cm] {geometry}       


\begin {document}


\fancyhead[CE,CO,LE,LO,RE,RO]{} %% clear out all headers
       \centering TEXT & \centering \LARGE{Another text} & Version: 2 & Page: \hspace{0.5pt}\thepage \hspace{0.5pt} / \pageref{LastPage} \\
\multicolumn{4}{c}{Long text}\\

This works fine when used in document body, but I cant compile it in header and I cant find/figure out the reason. Any help or suggestion would be great!

Thank you in advance, Tomáš

  • 1
    table is a floating environment. Remove it (and the extra \end{tabular} in your code) and you shall be happy. – campa Jun 13 '18 at 7:35
  • @campa Thank you! Such simple solution was unexpected on my part! – Tomáš Kruliš Jun 13 '18 at 10:10

Although your problem is well solved in the campa's comment:

mwe The source code:

\documentclass [a4paper, 12pt] {article}

% Code not relevant for tables, just to glamourize the examples :)
\parskip2em\parindent0pt  % warning: non LaTeX mode, good only for idlers
\usepackage[margin=2.25cm,showframe]{geometry}% show margins in green:
\def\Gm@vrule{\color{green}\vrule width 1pt height\textheight depth\z@}%
\def\longtext{So long text that will have linebreaks or not (that should not matter). Please, do not center if there are some line breaks.}
% Required for tables: 


\begin {document}

Your corrected code could produce  ...

\setlength{\tabcolsep}{12pt} % right LateX mode of setting  lenghts
\centering TEXT & \centering \LARGE{Another text} & Version: 2 & Page: \hspace{0.5pt}\thepage \hspace{0.5pt} / \pageref{LastPage} \\\hline
\multicolumn{4}{c}{Not so long text that fit only in one line, but see the right  margin ...}\\

... or ...

\setlength{\tabcolsep}{12pt} % right LateX mode of setting  lenghts
\centering TEXT & \centering \LARGE{Another text} & Version: 2 & Page: \hspace{0.5pt}\thepage \hspace{0.5pt} / \pageref{LastPage} \\\hline

But with a simpler code using \verb|hhline| and \verb|tabularx| thera are not this problem: 


TEXT & \LARGE{Another text} & Version: 2 & Page: \thepage/\pageref{LastPage}

Off-topic: although indiscutibly is a matter of individual taste, only in case that you want to escape from that  look of prehistoric HTML table, I would suggest some alternatives:


TEXT & \LARGE{Another text} & Version: 2 & Page: \thepage/\pageref{LastPage} \\\hline

\cellcolor{blue!25}TEXT & \cellcolor{blue!20}\LARGE{Another text} & \cellcolor{blue!15} Version: 2 & Page: \thepage/\pageref{LastPage} \\

  • Thank you for such an elaborate answer! Since campa's answer is written as a comment, allow me to put your reaction as formal answer. Actually, I bumped into situation 2, managed to get control of the text by using environment \mypage (which felt weird even to me as a beginner :D). Sadly I cannot go through the whole code to learn from it, right now I am at work and also was charged to focus on different project, but tested it in my document and works perfectly :) – Tomáš Kruliš Jun 14 '18 at 11:31
  • On the formating note – this document is kind of specific, so I cannost use colors, for instance, but I definitely think about more interesting design of the table. With regards Tomáš – Tomáš Kruliš Jun 14 '18 at 11:32

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.