I am trying to use pdflatex and change the font to greek by using both XeLaTeX and pdflatex.
XeLaTeX works perfect and inside section title it uses bold selected font for greek. But pdflatex fails to make the greek part inside the section title bold.
My code (MWE with some commented out alternative tests) is this:
\def\UseXeLaTeX{1}
\documentclass[12pt]{article}
\ifnum\UseXeLaTeX=0
\usepackage[utf8]{inputenc} % utf8 is the preferred input encoding
\usepackage[greek.ancient,english]{babel} %koleygr:BF4 These coammnds are for LaTeX and pdflatex but we can't change font while changing language and thus we will use XeLaTeX
\usepackage[LGR,T1]{fontenc} %koleygr:BF4 Same as above
\else
\usepackage{polyglossia} %koleygr: Replacing commands to use XeLaTeX
\setmainlanguage{english}
\setotherlanguage{greek}
\fi
\ifnum\UseXeLaTeX=0
\usepackage{tgpagella} % Set the font TEX Gyre Pagella
\usepackage[scaled=0.875]{helvet} % Use helvetica for sans serif (phv)
\renewcommand{\sfdefault}{phv}
\usepackage{tgheros} %Use TeX Gyre Heros for greek (qhv)
\newcommand*{\mygreekfont}{\fontfamily{qhv}\selectfont}
\else
\setmainfont{TeX Gyre Pagella}
\setsansfont[Ligatures=TeX]{TeX Gyre Heros}
\newfontfamily\helvet[Mapping=tex-text]{TeX Gyre Heros}
\newfontfamily\greekfont[Mapping=tex-text]{GFS Didot}
\fi
\newcommand{\fgreek}[1]{\ifnum\UseXeLaTeX=1 \textgreek{#1}\else\foreignlanguage{greek}{%\fontfamily{qhv}\selectfont
%\renewcommand{\familydefault}{qhv}
\mygreekfont #1}\fi}
\newenvironment{mygreek}{\ifnum\UseXeLaTeX=1 \begin{greek}\else\begin{otherlanguage}{greek}%\fontfamily{qhv}\selectfont
%\renewcommand{\familydefault}{qhv}
\mygreekfont
\fi}{\ifnum\UseXeLaTeX=1 \end{greek}\else\end{otherlanguage}\fi}
\begin{document}
\tableofcontents
\section{Test Section}
Test english text
\section{A phrase from \fgreek{Σωκράτης}}
\begin{mygreek}
Ἓν οἶδα ὅτι οὐδὲν οἶδα
\end{mygreek}
\end{document}
The XeLaTeX output is the expected:
But pdflatex gives (with all tests):
Am I doing something wrong, or it is a font matter? (Font supposed to be the same but in pdflatex comes from the package)
\def\UseXeLaTeX{1}
) with\def\UseXeLaTeX{0}
...cmr
and the problem remains... I forgot to add a\protect
comand there too. This solves the problem with other fonts. Thanks