0

I am trying to add some separation between my header and my text in IEEEtran style document in latex.

enter image description here

\documentclass[journal, a4paper, 11pt]{IEEEtran}
\IEEEoverridecommandlockouts
\linespread{1.25}\selectfont

\usepackage{graphicx} \usepackage{tabularx} \usepackage{multirow} \usepackage{multicol} \usepackage[table,xcdraw]{xcolor} \usepackage{tabulary} \usepackage{url}
\usepackage{amsmath} \usepackage[left=1.5cm,right=1.5cm,top=1.5cm,bottom=1.5cm]{geometry} \usepackage{float}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% ENCABEZADO DE LAS PÁGINAS TIPO UNICAFAM %%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\MYhead}{\smash{\scriptsize \hfil\parbox[t][\height][t]{\textwidth}{\centering \begin{picture}(0,0) \put(-30,-27){\includegraphics[width=17mm]{images/00_general/cranfield_university_main_logo.png}} \end{picture} \hspace{6.4cm} PRÁCTICA DE CIRCUITOS I \hspace{5.15cm} Versión 1.0\ \hspace{5.2cm} DEPARTAMENTO DE INGENIERÍA DE TELECOMUNICACIONES \hspace{3cm} Periodo 2022-II\ \underline{\hspace{ \textwidth}}}\hfil\hbox{}}}

\makeatletter % normal pages \def\ps@headings{% \def@oddhead{\MYhead}% \def@evenhead{\MYhead}}% % title page \def\ps@IEEEtitlepagestyle{% \def@oddhead{\MYhead}% \def@evenhead{\MYhead}}% \makeatother % make changes take effect \pagestyle{headings} % adjust as needed \addtolength{\footskip}{0\baselineskip} \addtolength{\textheight}{-10\baselineskip}

\begin{document} \pagenumbering{Roman}

% Titulo \title{\textbf{\huge{This is the title}} \ \vspace{5mm} \large{Group Design Project} \ \vspace{5mm} \large{\textbf{Astronautics and Space Engineering MSc.}} \ \vspace{3mm} \normalsize{Academic year: 2022-2023} }

% author names \author{\textbf{\textbf{Yi Qiang Ji Zhang}}\textsuperscript{1} \ \vspace{3mm} \textbf{Supervisors}: Dr. s\textsuperscript{1} & Dr. s\textsuperscript{1} \ \vspace{3mm}

    \begin{figure}[H]
        \centering
        \includegraphics[width=0.2\textwidth]{images/00_general/cranfield_university_main_logo.png}
        \hspace{3mm}
        \includegraphics[width=0.2\textwidth]{images/00_general/Cranfield_Crest.jpg}
    \end{figure}

    \begin{flushleft}
    \small{\textsuperscript{1}\textit{School of Aerospace, Transport and Manufacturing, Cranfield University, United Kingdom}}
    \end{flushleft}


}% <-this % stops a space

\onecolumn \maketitle \vspace{-10mm}

\end{document}

I tried adding \vspace{10mm} and oher approaches but nothing changes it.

I also want the page numbering to appear in the right (where there is Version 1.0 written), how can I add that as well to my header?

  • If this is for publication, don't mess with the page format. I would be very surprised if company or university logos were allowed at all, much less in the heaser. – John Kormylo Jun 06 '23 at 12:10
  • If it is for a university submission, usually they provide Latex templates for this kind of thing. I would try to find them first! If they exist, you will save yourself a lot of time. – Jes Jun 06 '23 at 13:30
  • @JohnKormylo This is for university, it's a personal template I am crafting for my assignments. – Yi Qiang Ji Jun 06 '23 at 14:26
  • @Jes I am doing this for an assignment myself and there is no restriction. My uni provides some templates but I want to add something :) – Yi Qiang Ji Jun 06 '23 at 14:27

2 Answers2

1

A workaround is to include the vspace* command directly within the title one:

\title{ \vspace*{5mm} \textbf{\huge{This is the title}} \\ 

That worked for me to shift everything down.

Regarding changing the page numbering to the top right, you can modify the \MYhead command to achieve so via the \thepage command. Do note that, in order for the first page to be also in roman, you need to write the \pagenumbering{Roman} before the \begin{document}. The modification is as such:

\newcommand{\MYhead}{\smash{\scriptsize
\hfil\parbox[t][\height][t]{\textwidth}{\centering
\begin{picture}(0,0) \put(-30,-27){\includegraphics[width=17mm]{images/00_general/cranfield_university_main_logo.png}} \end{picture} \hspace{6.4cm}
PRÁCTICA DE CIRCUITOS I \hspace{5.15cm} Versión 1.0 - Page \thepage\\ % <-- HERE!
\hspace{5.2cm} DEPARTAMENTO DE INGENIERÍA DE TELECOMUNICACIONES \hspace{3cm} Periodo 2022-II\\
\underline{\hspace{ \textwidth}}}\hfil\hbox{}}}

And finally, the resulting code with the modifications:

\documentclass[journal, a4paper, 11pt]{IEEEtran}
\IEEEoverridecommandlockouts
\linespread{1.25}\selectfont

\usepackage{graphicx} \usepackage{tabularx} \usepackage{multirow} \usepackage{multicol} \usepackage[table,xcdraw]{xcolor} \usepackage{tabulary} \usepackage{url}
\usepackage{amsmath} \usepackage[left=1.5cm,right=1.5cm,top=1.5cm,bottom=1.5cm]{geometry} \usepackage{float}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% ENCABEZADO DE LAS PÁGINAS TIPO UNICAFAM %%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\MYhead}{\smash{\scriptsize \hfil\parbox[t][\height][t]{\textwidth}{\centering \begin{picture}(0,0) \put(-30,-27){\includegraphics[width=17mm]{images/00_general/cranfield_university_main_logo.png}} \end{picture} \hspace{6.4cm} PRÁCTICA DE CIRCUITOS I \hspace{5.15cm} Versión 1.0 - Page \thepage\ \hspace{5.2cm} DEPARTAMENTO DE INGENIERÍA DE TELECOMUNICACIONES \hspace{3cm} Periodo 2022-II\ \underline{\hspace{ \textwidth}}}\hfil\hbox{}}}

\makeatletter % normal pages \def\ps@headings{% \def@oddhead{\MYhead}% \def@evenhead{\MYhead}}% % title page \def\ps@IEEEtitlepagestyle{% \def@oddhead{\MYhead}% \def@evenhead{\MYhead}}% \makeatother % make changes take effect \pagestyle{headings} % adjust as needed \addtolength{\footskip}{0\baselineskip} \addtolength{\textheight}{-10\baselineskip}

\pagenumbering{Roman}

\begin{document}

% Titulo \title{ \vspace*{5mm} \textbf{\huge{This is the title}} \ \vspace{5mm} \large{Group Design Project} \ \vspace{5mm} \large{\textbf{Astronautics and Space Engineering MSc.}} \ \vspace{3mm} \normalsize{Academic year: 2022-2023} }

% author names \author{\textbf{\textbf{Yi Qiang Ji Zhang}}\textsuperscript{1} \ \vspace{3mm} \textbf{Supervisors}: Dr. s\textsuperscript{1} &amp; Dr. s\textsuperscript{1} \ \vspace{3mm}

    \begin{figure}[H]
        \centering
        \includegraphics[width=0.2\textwidth]{images/00_general/cranfield_university_main_logo.png}
        \hspace{3mm}
        \includegraphics[width=0.2\textwidth]{images/00_general/Cranfield_Crest.jpg}
    \end{figure}

    \begin{flushleft}
    \small{\textsuperscript{1}\textit{School of Aerospace, Transport and Manufacturing, Cranfield University, United Kingdom}}
    \end{flushleft}


}% <-this % stops a space

\onecolumn \maketitle

asdsda

\newpage

asdasd

\newpage

asdasd

\end{document}

Jes
  • 839
  • Thanks!! That fixes the title page!!! But the other subsequent pages still have the same problem... is there a global command that can be applied to all pages? – Yi Qiang Ji Jun 06 '23 at 14:24
  • 1
    I am uncertain if something like that exists. What about changing the approach to generating the header? I will post a new answer using 'tikz', which is a powerful tool for things like this! – Jes Jun 07 '23 at 15:58
1

Another possibility to generate the header is to use tikz with the options of remember picture, overlay,transform shape, which basically overlaps a tikz-generated header on top of the page. At the end of this message, I put the code to do that. What I am doing:

  1. I changed the top margin to 2.5 cm via the geometry package to leave space for the header.
  2. I generated the header using tikz and multiline nodes, since it allows for centering of the text without having to guess its position via hspace.
  3. I place the different nodes approximately 1cm above the text body and the line between them via the calc library.

Do note that all of this positioning is manual. If you change the value for the top margin in the declaration of the geometry package, you will need to adjust the different sizes manually.

The text does not overlap the header because the header has been placed above the text body (!) which removes the problem that you had before. Other possibility to achieve a similar effect without having to change how to generate the header can be enveloping your header in a minipage environment with a set height, but I am not sure if this will work.

I hope it helps you!

The result is the following: enter image description here

And the code to achieve this:

\documentclass[journal, a4paper, 11pt]{IEEEtran}
\IEEEoverridecommandlockouts
\linespread{1.25}\selectfont

\usepackage{graphicx} \usepackage{tabularx} \usepackage{multirow} \usepackage{multicol} \usepackage[table,xcdraw]{xcolor} \usepackage{tabulary} \usepackage{url}
\usepackage{amsmath} \usepackage[left=1.5cm,right=1.5cm,top=2.5cm,bottom=1.5cm]{geometry} %<- Here I changed the top value to make space for the header! \usepackage{float} \usepackage{tikz} % Extra! \usepackage{tikzpagenodes} % To employ the command "current page text area" for positioning of tikz nodes \usetikzlibrary{calc} % To help with positioning \usepackage{lipsum} % To generate fake text

%\usepackage{showframe} % To show page geometry %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% ENCABEZADO DE LAS PÁGINAS TIPO UNICAFAM %%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\MYhead}{% \scriptsize \hfil\parbox[t][\height][t]{\textwidth}{% \centering \begin{picture}(0,0) \put(-30,-27){% \includegraphics[width=17mm]{example-image-a}}% \end{picture}% \hfill PRÁCTICA DE CIRCUITOS I \hfill Versión 1.0 - Page \thepage\ \hfill DEPARTAMENTO DE INGENIERÍA DE TELECOMUNICACIONES \hfill Periodo 2022-II\ \underline{\hspace{\textwidth}}}\hfil\hbox{}}

\newcommand{\tikZHeader}{% % Useful links: % For relative positioning: https://tex.stackexchange.com/questions/89588/positioning-relative-to-page-in-tikz % Ikz and overlay: https://tex.stackexchange.com/questions/121393/tikz-header-and-footer-across-top-and-bottom-of-bulletin-newsletter-page % Calc library: https://tex.stackexchange.com/questions/617027/how-to-add-a-few-points-to-the-current-page-text-area-of-tikz % Maybe the header is better with the fancyheader package? : https://www.overleaf.com/learn/latex/Headers_and_footers \begin{tikzpicture}[remember picture, overlay,transform shape] %- Node with university logo (left side) -% \node (leftText) [anchor = south west, inner sep=0pt] % Anchors are tricky! at ($(current page text area.north west) - (0cm,-1cm)$) % Put the node at the upper left (north west) side of the body of text. Then add 1 cm towards the top of the page, so it is separated from the text. {% \includegraphics[width=17mm]{example-image-a}% }; %- Node with text on center of page -% \node (centerText) [anchor = south, inner sep=0pt, style={align=center, font = \scriptsize}] at ($(current page text area.north) - (0cm,-1cm)$) % Put the node at the upper center (north) side of the body of text. Then add 1 cm towards the top of the page, so it is separated from the text. {% PRÁCTICA DE CIRCUITOS I \ DEPARTAMENTO DE INGENIERÍA DE TELECOMUNICACIONES \ Periodo 2022-II }; %- Node with text on right side -% \node (rightText) [anchor = south east, inner sep=0pt, style={align=right, font = \scriptsize}] at ($(current page text area.north east) - (0cm,-1cm)$) % Put the node at the upper right (north east) side of the body of text. Then add 1 cm towards the top of the page, so it is separated from the text. {% Versión 1.0 - Page \thepage }; %- Line below header -% \draw ($(current page text area.north west) - (0cm,-0.5cm)$) -- ($(current page text area.north east) - (0cm,-0.5cm)$) ; \end{tikzpicture} }

\makeatletter % normal pages \def\ps@headings{% \def@oddhead{\tikZHeader}% \def@evenhead{\tikZHeader}}% % title page \def\ps@IEEEtitlepagestyle{% \def@oddhead{\tikZHeader}% \def@evenhead{\tikZHeader}}% \makeatother % make changes take effect \pagestyle{headings} % adjust as needed \addtolength{\footskip}{0\baselineskip} \addtolength{\textheight}{-10\baselineskip}

\pagenumbering{Roman}

\begin{document}

% Titulo \title{ \vspace*{15mm} \textbf{\huge{This is the title}} \ \vspace{5mm} \large{Group Design Project} \ \vspace{5mm} \large{\textbf{Astronautics and Space Engineering MSc.}} \ \vspace{3mm} \normalsize{Academic year: 2022-2023} }

% author names \author{\textbf{\textbf{Yi Qiang Ji Zhang}}\textsuperscript{1} \ \vspace{3mm} \textbf{Supervisors}: Dr. s\textsuperscript{1} &amp; Dr. s\textsuperscript{1} \ \vspace{3mm}

    \begin{figure}[H]
        \centering
        \includegraphics[width=0.2\textwidth]{example-image-b}
        \hspace{3mm}
        \includegraphics[width=0.2\textwidth]{example-image-c}
    \end{figure}

    \begin{flushleft}
    \small{\textsuperscript{1}\textit{School of Aerospace, Transport and Manufacturing, Cranfield University, United Kingdom}}
    \end{flushleft}


}% <-this % stops a space

\onecolumn \maketitle

\newpage

\lipsum[10-25] % fake text

\end{document}

Jes
  • 839
  • That is a really clever way to do it! Thanks a lot Jes! I did not thought of that and it just works ahahah! Maybe there is other more "elegant" ways to solve it but for now I think it's really good approach! Thanks a lot for your time and help! – Yi Qiang Ji Jun 08 '23 at 16:11
  • 1
    Glad to help! Sometimes I like to play around with tikz, so I saw the chance and took it :) – Jes Jun 08 '23 at 19:51