3

I would like to create header with logo in center

enter image description here

\documentclass[11pt,a4paper]{report}
\usepackage[margin=0.5in]{geometry}
\usepackage{multicol}
\usepackage[french]{babel}
\usepackage{fontspec}
\usepackage{graphicx}
\usepackage{amsthm,amssymb,amsfonts,mathtools}
\newcommand{\centerbox}[1]% #1 = text
{\bgroup% use local definitions
  \parskip=0pt
  \sbox0{\fbox{#1}}
  \dimen0=\dimexpr 0.5\textwidth - 0.5\wd0\relax
  \par\noindent\rule{\dimen0}{0.8pt}\box0\rule{\dimen0}{0.8pt}\par
\egroup}

\usepackage{xhfill}
\usepackage{fancyhdr}
\usepackage[svgnames]{xcolor}
%\usepackage[most]{tcolorbox}
\tcbuselibrary{skins,breakable,xparse}
\usepackage{tikz}
  \usetikzlibrary{shapes,arrows,fit,calc,positioning}
  \tikzset{box/.style={draw, rectangle, thick, text centered, minimum height=3em}}
  \tikzset{line/.style={draw, thick, -latex'}}

\newlength\TextBoxWd% width of the text boxes
\newlength\TextBoxSep% separation of the text boxes
\newlength\TextBoxHt% height of the text boxes

\setlength\TextBoxWd{\marginparwidth}
\setlength\TextBoxSep{\marginparsep}
\setlength\TextBoxHt{2cm}

\newcommand\ThickTitleRule{\xrfill[0.5ex]{3pt}}

\newcommand\Title[4]{%
\begingroup
  \setlength\parindent{0pt}%
  \par
  \makebox[\linewidth]{%
   % \fbox{\parbox[t][\TextBoxHt][c]{\TextBoxWd}{\raggedright#3}}\hspace{\TextBoxSep}%
    \parbox[t]{\textwidth}{%
      \leavevmode
      \centering
      \ThickTitleRule\quad{\scshape\bfseries\itshape#1}\quad\ThickTitleRule\par
      \vskip-0.2\baselineskip
      \rule{\textwidth}{2pt}\par\vskip-.8\baselineskip% Thick horizontal line
      \rule{\textwidth}{0.4pt}%Thin horizontal line
      \par\vskip0.75ex
      {\Large\scshape\bfseries\itshape#2\par}% Title
      \rule{\textwidth}{0.4pt}\par\par\vskip-.7\baselineskip% Thin horizontal line
      \rule{\textwidth}{2pt}% Thick horizontal line
    }%
   % \hspace{\TextBoxSep}\fbox{\parbox[t][\TextBoxHt][c]{\TextBoxWd}{\raggedright#4}}\par%
  }%
  \vskip\baselineskip
\endgroup
}

%========================================================================================
\begin{document}

\Title{Mohcine}{The Kingdom of Morocco \hfill  
\begin{center}
\includegraphics[width=10cm,height=4cm]{1.jpg}
\end{center} \hfill Semester $1$\\
High School: Educ \hfill \hfill  Level: SM \\
\text{address, country} \hfill \hfill Year: 2016--2017 \\
 \textbf{Trainee Teacher :Educ \hfill  Mohcine}}}{}{}
\bigskip

\end{document}
2

A solution based on tabularx and makecell:

\documentclass[11pt,a4paper, svgnames, demo]{report}
\usepackage[margin=0.5in]{geometry}
\usepackage{multicol}
\usepackage[english, french]{babel}
\usepackage{fontspec}
\usepackage{graphicx}
\usepackage{amsthm,amssymb,amsfonts,mathtools}
\newcommand{\centerbox}[1]% #1 = text
{\bgroup% use local definitions
  \parskip=0pt
  \sbox0{\fbox{#1}}
  \dimen0=\dimexpr 0.5\textwidth - 0.5\wd0\relax
  \par\noindent\rule{\dimen0}{0.8pt}\box0\rule{\dimen0}{0.8pt}\par
\egroup}

\usepackage{xhfill}
\usepackage{fancyhdr}
\usepackage[]{xcolor}
%\usepackage[most]{tcolorbox}
%\tcbuselibrary{skins,breakable,xparse}
\usepackage{tikz}
  \usetikzlibrary{shapes,arrows,fit,calc,positioning}
  \tikzset{box/.style={draw, rectangle, thick, text centered, minimum height=3em}}
  \tikzset{line/.style={draw, thick, -latex'}}

\newlength\TextBoxWd% width of the text boxes
\newlength\TextBoxSep% separation of the text boxes
\newlength\TextBoxHt% height of the text boxes

\setlength\TextBoxWd{\marginparwidth}
\setlength\TextBoxSep{\marginparsep}
\setlength\TextBoxHt{2cm}

\newcommand\ThickTitleRule{\xrfill[0.5ex]{3pt}}

\newcommand\Title[4]{%
\begingroup
  \setlength\parindent{0pt}%
  \par
  \makebox[\linewidth]{%
   % \fbox{\parbox[t][\TextBoxHt][c]{\TextBoxWd}{\raggedright#3}}\hspace{\TextBoxSep}%
    \parbox[t]{\textwidth}{%
      \leavevmode
      \centering
      \ThickTitleRule\quad{\scshape\bfseries\itshape#1}\quad\ThickTitleRule\par
      \vskip-0.2\baselineskip
      \rule{\textwidth}{2pt}\par\vskip-.8\baselineskip% Thick horizontal line
      \rule{\textwidth}{0.4pt}%Thin horizontal line
      \par\vskip0.75ex
      {\Large\scshape\bfseries\itshape#2\par}% Title
      \rule{\textwidth}{0.4pt}\par\par\vskip-.7\baselineskip% Thin horizontal line
      \rule{\textwidth}{2pt}% Thick horizontal line
    }%
   % \hspace{\TextBoxSep}\fbox{\parbox[t][\TextBoxHt][c]{\TextBoxWd}{\raggedright#4}}\par%
  }%
  \vskip\baselineskip
\endgroup
}

\usepackage{makecell, tabularx}
%========================================================================================
\begin{document}
{\selectlanguage{english}
\Title{Mohcine}{\centering The Kingdom of Morocco\\[1.5ex]%
\begin{tabularx}{\textwidth}{@{}>{\raggedright\bfseries\arraybackslash}Xc>{\bfseries\arraybackslash}X@{}}
\makecell[lb]{High School: Educ\\
address, country\\
Trainee Teacher: \\%
Educ}%
 & \includegraphics[width=0.4\textwidth, height=4cm]{1.jpg}
 & \makecell[rb]{Semester 1\\%
Level: SM\\%
Year: 2016-2017\\%
Mohcine}
 \end{tabularx} }{}{}}
\bigskip

\end{document} 

enter image description here

  • why when i add image.jpg still drakness – Educ Jan 8 '17 at 21:02
  • 1
    Do you mean you still obtain a black rectangle? That is because I added the [demo] option for graphicx, as I didn't have the image. Just remove the option. – Bernard Jan 8 '17 at 21:05
  • Thank you just i notice that i should add image with 100 pixels or i will get error that i have big image – Educ Jan 8 '17 at 21:15
  • 1
    The best thing to do is probably to fix a scaling rather than width and height (\includegraphics[scale=…]{image}). – Bernard Jan 8 '17 at 21:19
3

This should work :

 \usepackage{fancyhdr}
 \usepackage{graphicx}
 \fancypagestyle{logoheader}
 \fancyhead[LO,LE]{School \\ Adress \\ Teacher}
 \fancyhead[CO,CE]{\includegraphics{yourlogo}}
 \fancyhead[RO,RE]{Semester \\ Level \\ Year}

Then use \pagestyle{logoheader}.

You can customize it with some horizontal rules, it's easier than using tikz.

  • Obviously, if your logo is quite big, some tweakings should be made with `geometry" in order to find the right height for your header. – Rémi Nazin Jan 8 '17 at 21:00

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.