TransWikia.com

Tabular in header and footer, footer is out of page

TeX - LaTeX Asked by Bahman Mirzakhani on June 8, 2021

I have some problems. The footer is out of page and tables has moved left a bit. See in pictures.

documentclass[12pt]{article}
newlength{border}
setlength{border}{1cm}
usepackage{geometry}
geometry{left=2cm, right=2cm, top=border, bottom=border, includehead, includefoot}
usepackage{multirow}
usepackage{graphicx}
usepackage{tabularx}
usepackage{lastpage}
usepackage{array}
newcolumntype{x}{>{centeringarraybackslash}X}
newcolumntype{C}[1]{>{centeringarraybackslash}m{#1}}
usepackage{calc}
usepackage{fancyhdr}
fancypagestyle{mystyle}{%
    newlength{forheader}
    setlength{forheader}{(paperwidth-2border-textwidth)}
    fancyheadoffset{forheader}
    fancyfootoffset{forheader}
    newlength{tabhead}
    setlength{tabhead}{(textwidth+forheader)}
    fancyhf{}
    fancyhead[C]{%
        begin{tabularx}{tabhead}{C{3.5cm}|x|C{5cm}}
            multirow{3}{*}{includegraphics[width=2cm]{example-image}} &
            multirow{2}{*}{Text} &
            First
             cline{3-3}
            & & Second
             cline{3-3}
            & multirow{-2}{*}{Latin report title} & Third
             hline
        end{tabularx}
    }
    fancyfoot[C]{%
        begin{tabularx}{tabhead}{C{4cm}|x|C{4cm}}
            hline
            Page thepage{} of pageref{LastPage} &
            Text &
            Page thepage{} of pageref{LastPage}
        end{tabularx}
    }
    renewcommand{headrulewidth}{0pt}
}
usepackage{tikz}
usetikzlibrary{calc}
usepackage{eso-pic}
usepackage{lipsum}
AddToShipoutPictureBG{%
    begin{tikzpicture}[overlay,remember picture]
        draw[line width=1pt]
        ($ (current page.north west) + (border,-border) $)
        rectangle
        ($ (current page.south east) + (-border,border) $);
    end{tikzpicture}
}
pagestyle{mystyle}
headheight43.9pt
begin{document}
    lipsum
    
    lipsum
end{document} 

enter image description here


footer must be like header. In border!

enter image description here

One Answer

documentclass[12pt]{article}
newlength{border}
setlength{border}{1cm}
newlength{margins}
setlength{margins}{dimexprborder+1cm}
usepackage{geometry}
geometry{left=margins, right=margins, top=border, bottom=border, includehead, includefoot}
usepackage{multirow}
usepackage{graphicx}
usepackage{tabularx}
usepackage{lastpage}
usepackage{array}
newcolumntype{x}{>{centeringarraybackslash}X}
newcolumntype{C}[1]{>{centeringarraybackslash}m{#1}}
usepackage{fancyhdr}
fancypagestyle{mystyle}{%
    newlength{forheader}
    setlength{forheader}{dimexprpaperwidth-2border-textwidth}
    fancyheadoffset{forheader}
    fancyfootoffset{forheader}
    newlength{tabhead}
    setlength{tabhead}{dimexprtextwidth+forheader}
    fancyhf{}
    fancyhead[C]{%
        begin{tabularx}{tabhead}{C{3.5cm}|x|C{4cm}}
            multirow{3}{*}{includegraphics[width=2cm]{example-image}} &
            multirow{2}{*}{Text} &
            First 
            tabularnewline cline{3-3}
            & & Second 
            tabularnewline cline{3-3}
            & multirow{-2}{*}{Latin report title} & Third 
            tabularnewline hline
        end{tabularx}%
    }
    fancyfoot[C]{%
        raisebox{depth}{%
            begin{tabularx}{tabhead}{C{4cm}|x|C{4cm}}
                hline
                Page thepage{} of pageref{LastPage} &
                Text &
                Page thepage{} of pageref{LastPage}
            end{tabularx}%
        }%
    }
    renewcommand{headrulewidth}{0pt}
}
usepackage{tikz}
usetikzlibrary{calc}
usepackage{eso-pic}
usepackage{lipsum}
AddToShipoutPictureBG{%
    begin{tikzpicture}[overlay,remember picture]
        draw[line width=1pt]
        ($ (current page.north west) + (border,-border) $)
        rectangle
        ($ (current page.south east) + (-border,border) $);
    end{tikzpicture}
}
pagestyle{mystyle}
headheight43.9pt
setlength{textheight}{dimexprpaperheight-headheight-headsep-footskip-2border}
begin{document}
    lipsum
    
    lipsum
end{document}

Correct answer by Bahman Mirzakhani on June 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP