Text Formattingadding tables in the footer

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
alihaider82
Posts: 10
Joined: Tue Nov 02, 2010 11:44 am

adding tables in the footer

Post by alihaider82 »

I have made the required format with your help. I want to do something more. The latex code is written below:

Code: Select all

\documentclass[a4paper]{report}

\usepackage{tabularx}
\usepackage{fancybox}
\usepackage{titletoc}
\usepackage{graphicx}
\usepackage{color}
\usepackage{titling}
\usepackage{geometry}
\geometry{%
   left=1in,
   right=1in,
   top=1.5in,
   headsep=8pt,
   headheight=115pt,
   bottom=2.5in,
   footskip=8pt
}
\usepackage{fancyhdr}
\pagestyle{fancy}
\newlength{\hfwidth}
\setlength{\hfwidth}{\textwidth}
\addtolength{\hfwidth}{16pt}
\addtolength{\hfwidth}{2\fboxrule}
\renewcommand{\headrulewidth}{0pt}
\fancyhf{}
	\fancyhead[L]{\includegraphics[width=0.25\textwidth]{Sunset.jpg}}
	\fancyhead[C]{\color{blue}{\uppercase{chapter1}}}
	\fancyhead[R]{\includegraphics[width=0.25\textwidth]{Winter.jpg}}

\fancyfoot[L]{%
\vspace{0pt}\renewcommand{\arraystretch}{3}\begin{tabularx}{\hfwidth}{|X|X|X|X|} 
\hline 
A & B & C & D  \\ \hline
E &  F & Date: \today & Page~\thepage \\ \hline
\end{tabularx}}
I have attached the output of this as a *.jpg file. Refer to *.JPG;

1 - How to align CHAPTER1 in center header to the top or middle of the header?

2 - How to align right image in the header to the page border/frame?

3 - How can I merge cells A & B in the footer to print a single text entry like Title: \the title?

4 - How to adjust cell size (width) according to the text and how to change the font size in the footer and header?

Best Regards
Attachments
test001.jpg
test001.jpg (15.14 KiB) Viewed 1691 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

adding tables in the footer

Post by frabjous »

alihaider82 wrote:
1 - How to align CHAPTER1 in center header to the top or middle of the header?
You mean vertically? That's actually a little tricky to do. I'll put one way of doing it in a sample below; it involves merging the three part of the header and using hfill to align the images to the left and right.
2 - How to align right image in the header to the page border/frame?
That'll be covered in my answer to #1, though the real trick is that the frame is wider than the text block, and so you need to use a makebox to make the header bigger too.
3 - How can I merge cells A & B in the footer to print a single text entry like Title: \the title?
Use the \multicolumn command. I put this in my sample below.
4 - How to adjust cell size (width) according to the text and how to change the font size in the footer and header?
For adjusting cell size, you have already been instructed twice to read the documentation for the tabularx package, and show no sign of having done so. Do that, and you'll probably answer your own question. If not, well, I can't give any better answer unless you're more specific about what you want to do. Since you presumably want the table width to be no narrower and no wider than the frame, you can't make all the columns match their width to their contents, and you haven't made it clear which ones should stretch, which ones should wrap, etc.

As for changing font size, you do that the normal way with commands like \small, \large, \footnotesize, etc.

Code: Select all

\documentclass[a4paper]{report}
\usepackage{tabularx}
\usepackage{fancybox}
\usepackage{titletoc}
\usepackage{graphicx}
\usepackage{color}
\usepackage{titling}
\title{Some title long enough to go into next cell}
\usepackage{geometry}
\geometry{%
   left=1in,
   right=1in,
   top=1.5in,
   headsep=8pt,
   headheight=115pt,
   bottom=2.5in,
   footskip=8pt
}
\usepackage{fancyhdr}
\pagestyle{fancy}
\newlength{\hfwidth}
\setlength{\hfwidth}{\textwidth}
\addtolength{\hfwidth}{16pt}
\addtolength{\hfwidth}{2\fboxrule}
\renewcommand{\headrulewidth}{0pt}
\newcommand{\myvcenter}[1]{\ensuremath{\vcenter{\hbox{#1}}}}
\fancyhf{}
   \fancyhead{\makebox[\hfwidth]{\myvcenter{\includegraphics[width=0.25\textwidth]{Sunset.jpg}}
   \hfill
   \color{blue}{\uppercase{chapter1}}
   \hfill
   \myvcenter{\includegraphics[width=0.25\textwidth]{Winter.jpg}}}}


\fancyfoot[L]{%
\vspace{0pt}\renewcommand{\arraystretch}{3}\begin{tabularx}{\hfwidth}{|X|X|X|X|}
\hline
\multicolumn{2}{|l|}{Title: \thetitle} & C & D  \\ \hline
E & F  & Date: \today & Page~\thepage \\ \hline
\end{tabularx}}



\begin{document}
\fancypage{\setlength{\fboxsep}{8pt}\fbox}{}
Body text
\end{document}
Post Reply