TeX - LaTeX Asked on June 9, 2021
First of all I wanted to thank the community for all the help I’ve found on this website.
I’m relatively new to TeX and I’m trying to make headers composed with tables and pictures like the two ones below :
So I’ve tried to find similar topics on this forum and by merging them together Ive made the following code :
documentclass{article}
usepackage{makecell,multirow,tabularx}
usepackage{graphicx}
usepackage{lastpage}
usepackage[top=5cm,headheight=2cm]{geometry}
usepackage{lipsum}%
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{headrulewidth}{0pt}
fancyhead[CE,CO,LE,LO,RE,RO]{}
fancyhead[C]{%
centering
renewcommandarraystretch{1.3}
begin{tabularx}{textwidth}{|cX|p{10cm}|p{2cm}|}
hline
multirow{3}{*}{includegraphics[width=1.5cm]{Figures/logo.png}}
& & textbf{Title of the document} & page thepage of pageref{LastPage}
& & &
& & &
hline
& File name
& Revision & Activity domain :
hline
end{tabularx}%
}
begin{document}
lipsum[1-20]
end{document}
This code generates a header that is much simplier that the one I want, and with a lot of problems : the right column disapears, some text is overlapping the columns, …
How do you think I could improve my code to make this work?
Thanks a lot for your help,
Gary
I think this code is close to what you want.
documentclass{article}
usepackage{fancyhdr}
usepackage{kantlipsum} % dummy text
usepackage{graphicx}
usepackage{multirow}
usepackage{bigstrut,array}
usepackage{lastpage}
usepackage[top=5cm, bottom=3cm, left=2.5cm, right=2cm, headheight=3.5cm]{geometry}
%usepackage{showframe} %added for testing
%renewcommand*ShowFrameColor{color{red}} %added for testing
fancypagestyle{firststyle}{%
fancyhf{}
fancyfoot[C]{thepage}
fancyhead[L]{
textsf{bfseries%
begin{tabular*}{textwidth}{@{extracolsep{fill}}|c|c|c|c|c|c|}
cline{1-6}
multirow{4}[8]{*}{includegraphics[height=0.10textwidth,width=0.10textwidth]{example-image-a}} & multicolumn{3}{>{centeringarraybackslash}p{0.60textwidth}|}{multirow{4}[8]{*}{large Title}} & multicolumn{2}{>{raggedrightarraybackslash}p{0.20textwidth}|}{footnotesize File name: } bigstrut
cline{5-6}
& multicolumn{3}{c|}{} & multicolumn{1}{l|}{footnotesize Revision: XXX} & multicolumn{1}{p{40pt}|}{footnotesize{page thepage of pageref{LastPage}}} bigstrut
cline{5-6}
& multicolumn{3}{c|}{} & multicolumn{2}{l|}{footnotesize Efective date:} bigstrut
cline{5-6}
& multicolumn{3}{c|}{} & multicolumn{2}{l|}{footnotesize Activity domain: } bigstrut
cline{1-6}
multicolumn{6}{|c|}{} bigstrut
cline{1-6}
end{tabular*}%
}}}
pagestyle{fancy}{%
fancyhead[L,R]{}
fancyhead[L]{%
textsf{bfseries%
begin{tabular*}{textwidth}{@{extracolsep{fill}}|c|c|c|c|c|c|}
cline{1-6}
multirow{4}[8]{*}{includegraphics[height=0.10textwidth,width=0.10textwidth]{example-image-a}} & multicolumn{4}{>{centeringarraybackslash}p{0.7textwidth}|}{multirow{4}[7]{*}{large Title}} & multicolumn{1}{>{centeringarraybackslash}p{0.1textwidth}|}{multirow{4}[6]{*}{footnotesize{page thepage of pageref{LastPage}}} }bigstrut[t]
multicolumn{1}{|c|}{} & multicolumn{4}{c|}{} &
multicolumn{1}{|c|}{} & multicolumn{4}{c|}{} &
multicolumn{1}{|c|}{} & multicolumn{4}{c|}{} &
multicolumn{1}{|c|}{} & multicolumn{4}{c|}{} & bigstrut[b]
cline{1-6}
multicolumn{2}{|>{centeringarraybackslash}p{0.3textwidth}|}{File name: } & multicolumn{2}{>{centeringarraybackslash}p{0.3textwidth}|}{Revision:} & multicolumn{2}{>{centeringarraybackslash}p{0.3textwidth}|}{Activity domain: } bigstrut[t]
cline{1-6}
end{tabular*}%
}}}
renewcommand{headrulewidth}{0pt}
begin{document}
thispagestyle{firststyle}
kant[1-34]
end{document}
The fancypagestyle{firststyle}
is applied only to the fist page, then the fancy style is used for the following pages.
The headers are similar, tables using tabular*
to set the width, and some multirow
& multicolumn
to make the desired design. The packages multirow
, array
and bigstrut
are needed to compile.
If you want to visualize the layout, uncomment the two lines marked as added for testing
.
It is useful when dealing with geometry
.
Task left for the reader: For an operative and reusable solution you could define commands like
newcommand{wtitle}{This is the title of the work}
newcommand{wrevision}{Rev. 4a}
newcommand{wfilename}{firstproposal.tex}
and so on. Then insert these commands in the appropriator places of the template of the two tables.
Answered by Simon Dispa on June 9, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP