0

Hello everybody!

I am trying to get a Barcode in the Center head [chead] on every page like this work enter image description here

First I decided to put the barcode inside a header. This worked butenter image description here The code I had for the barcode:

\documentclass[paper=a4,12pt]{article}
\usepackage{fancyhdr}
%fancyhdr hiya li kadir khat asfal wa a3la waraka
\usepackage{lipsum}
\usepackage{pstricks}
\usepackage{pst-barcode}
\usepackage{graphicx}
\usepackage[right=2cm,left=2cm,top=1.6cm,bottom=2cm]{geometry}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{polyglossia}
\setdefaultlanguage[calendar=gregorian,locale=morocco]{arabic}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.4,]{Amiri}
\newfontfamily\arabicfontsf[Script=Arabic,Scale=1.4,]{Amiri}
\newfontfamily\khat[Script=Arabic,Scale=1.4,]{ae_Cortoba}
\setotherlanguage{french}
\parindent=0pt
\pagestyle{fancy}
%fancy tar9im wara9a 
\renewcommand{\footrulewidth}{2pt}
\renewcommand{\headrulewidth}{2pt}
\lhead{تاك}
\chead{ \begin{pspicture}(50mm,30mm)
        \psbarcode{978-3-86541-114}{includetext}{isbn}
\end{pspicture}}
\rhead{المستوى}
\lfoot{انتهى}
\cfoot{الصفحة
    $ 1 $
    من
    $ 1 $}
\rfoot{اقلب الصفحة}
\mathversion{bold}
\begin{document}
    \centerline{\textarabic{\khat وزارة التربية الوطنية والتعليم الأولي و الرياضة}}
    الثانوية الاعدادية الزهراء
    \hfill
    %hfill taktab mo9abil
    السنة الدراسية :
    $2022-2021$\\
المستوى : ثانية علوم تجريبية
\hfill
المدة :
$1$
سا\\

\rule{\textwidth}{2pt}
\centerline{الفرض الأول في مادة : الرياضيات}\\
\rule{\textwidth}{2pt}\\
\underline{التمرين الأول :
    ($ 05 $
    نقط)}\\
عين الكتابة العلمية للعدد :
$ 0.01234567 $\\
\begin{minipage}{10cm}
    ليكن الشكل المقابل هو التمثيل المبياني لدالة 
    $ f $
    معرفة بالعبارة :
    $ f(x)=x+1 $
\end{minipage}\hfill
\begin{minipage}{6cm}
    \includegraphics[scale=0.6]{tex}
\end{minipage}\\
\underline{التمرين الثاني}\\
نص عربي\\
$ \mathop {\lim }\limits_{x \to  + \infty } f(x) $

\lipsum

\end{document}

Any ideas

2 Answers2

1

The barcode has a height of 30 mm. So in the geometry settings you must include a head height of at least of this size.

Also, the barcode needs to be moved for better centering.

c

\documentclass[paper=a4,12pt]{article}
\usepackage{fancyhdr}
%fancyhdr hiya li kadir khat asfal wa a3la waraka
\usepackage{lipsum}
\usepackage{pstricks}
\usepackage{pst-barcode}
\usepackage{graphicx}
\usepackage[right=2cm,left=2cm,top=1.6cm,bottom=2cm,
 headheight=90pt, includehead
 ]{geometry} %changed <<<<<<
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{polyglossia}

\parindent=0pt \pagestyle{fancy} %fancy tar9im wara9a \renewcommand{\footrulewidth}{2pt} \renewcommand{\headrulewidth}{2pt}

\chead{\begin{pspicture}(-8mm,-2mm)(42mm,28mm)% center/adjust position changed <<<<<< \psbarcode{978-3-86541-114}{includetext}{isbn} \end{pspicture}}

\mathversion{bold} \begin{document} \lipsum
\end{document}

Simon Dispa
  • 39,141
0

It is difficult to test your example, because it does not compile out of the box. I do not know how you compile it (xelatex? lualatex? How do you obtain the code?)

But one educated guess (but just a guess) is that you ignored this warning:

lilla.tex|| Package fancyhdr Warning: \headheight is too small (12.0pt):  Make it at least 90.11264pt, for example:
\setlength{\headheight}{90.11264pt}. 
You might also make \topmargin smaller to compensate: 
\addtolength{\topmargin}{-78.11264pt}.

So try to add, before \begin{document}, the suggested commands, and try again:

\setlength{\headheight}{90.11264pt}\addtolength{\topmargin}{-78.11264pt}

If that does not work, try to prepare an example that it's easy to test...

Rmano
  • 40,848
  • 3
  • 64
  • 125