4

I try to put italic text at the header - at the body of the document it's works fine, but at the header I can't see the italic font.
Here is MWE:

    % Preview source code

%% LyX 2.3.2-2 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[a4paper,english,hebrew,numbers=noenddot]{scrartcl}
\usepackage{fontspec}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength{\parindent}{0bp}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\newfontfamily\hebrewfont[Script=Hebrew]{David CLM}
\newfontfamily\hebrewfonttt[Script=Hebrew]{Miriam Mono CLM}
\newfontfamily\hebrewfontsf[Script=Hebrew]{Simple CLM}
\AtBeginDocument{
\renewcommand\footnoterule{%
  \kern -3pt
  \hbox to \textwidth{\hfill\vrule height 0.4pt width .4\textwidth}
  \kern 2.6pt
}}
\renewcommand{\labelenumii}{\labelenumi\arabic{enumii}.}
\lhead{aa\emph{aa}}

\makeatother

\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\begin{document}
\begin{english}[variant=american]%
aa\emph{aa}
\end{english}%

\end{document}

The output is:
enter image description here

Do you know how can I fix it?

Thank you!

1
  • 6
    The header and text fonts are different. The text font appears to be Computer Modern; I'm not sure about the font in the header, but since it's different, it may also go by different rules for handling \emph. – barbara beeton Mar 6 '19 at 1:47
8

For some reason, David CLM does not seem to contain Latin glyphs with an Italic shape. As an additional oddity Miriam Mono CLM slants in the opposite way to the other two fonts.

In your question, you have set the default language to Hebrew and the default font to David CLM. So this is what you get in your header. If you want English in your header and the default English font of Latin Modern Roman, you could use: \lhead{\textenglish{aa\emph{aa}}}, but then you won't get Hebrew if you want it of course.

Also, note that scrartcl gives a warning not to use fancyhdr with this class. KOMA-Script has its own way of customising headers and footers.

Have a look at this test to see what is going on:

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\newfontfamily\hebrewfont{David CLM}[Script=Hebrew]
\newfontfamily\hebrewfonttt{Miriam Mono CLM}[Script=Hebrew]
\newfontfamily\hebrewfontsf{Simple CLM}[Script=Hebrew]
\begin{document}
\LR{David CLM}
\medskip

עברית \LR{Latin (Upright)}

{\itshape עברית \LR{Latin (Italic)}}

{\bfseries עברית \LR{Latin (Bold)}}

{\bfseries\itshape עברית \LR{Latin (Bold Italic)}}

\bigskip
\sffamily
\LR{Simple CLM}
\medskip

עברית \LR{Latin (Upright)}

{\itshape עברית \LR{Latin (Italic)}}

{\bfseries עברית \LR{Latin (Bold)}}

{\bfseries\itshape עברית \LR{Latin (Bold Italic)}}

\bigskip
\ttfamily
\LR{Miriam Mono CLM}
\medskip

עברית \LR{Latin (Upright)}

{\itshape עברית \LR{Latin (Italic)}}

{\bfseries עברית \LR{Latin (Bold)}}

{\bfseries\itshape עברית \LR{Latin (Bold Italic)}}
\end{document}

output

2
  • It's working, thank you!! But I don't understand why at the text I get it italic and at the header not, because it should be the same font, right? what the \textenglish doing? – heblyx Mar 6 '19 at 7:58
  • @heblyx It's different because the language and therefore font is different. You have \begin{english} and \end{english} around the text that works in your main document. This changes the font away from David CLM. You don't have this in your header. \textenglish{} does the same as \begin...\end{english} but for short text within a paragraph. Is your document mainly in English or Hebrew? – David Purton Mar 6 '19 at 12:06
0

Try this:

\lhead{\textit{aa\emph{aa}}}

\textit is to command to put text in italic.

5
0

I've compiled using your source code. The solution is: you can change the family font using in header.

a) try this line:

\lhead{\textrm{ aa\emph{aa}}}

the \textrm is to set serif (roman).

b) you can use \textsf to set sans serif family, try this line:

\lhead{\textrm{ aa\emph{aa}}}

c) you can use \texttt to set typewriter (monospace) family, try this line:

\lhead{\texttt{ aa\emph{aa}}}
1
  • 1
    Are you sure \textrm works? It does not work for me and I wouldn't expect different output since this is the default font family in use. The other two do work, but this changes the font which the OP might not want. – David Purton Mar 6 '19 at 6:05

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.