1

Some kind souls mentioned in some of my past questions that my using \usepackage{fontspec} is wrong. One of them suggested that I use \setmainfont[Scale=1.0, Ligatures={Common, Rare, TeX}]{Palatino Linotype}, but it failed to work as I need to produce a lot of letters with unusual accents and symbols, such as \ae or \'{\"{u}} or {\~o}, among others.

All I'm trying to do is use Candara for my chapters and sections/subsections, etc., and something like Palatino for the core text.

LaTex Commands used for my document

% PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[oneside,centered,twocolumn]{book}
%\documentclass[a4paper,oneside,centered,twocolumn]{book}
\special{papersize=215.9mm,279.4mm}
%\usepackage[top=3cm, bottom=3.2cm, left=2.5cm, right=2.5cm]{geometry}
\usepackage[english]{babel}

\usepackage{tocloft} % Customization of TOC LOF LOT
\usepackage[table,xcdraw]{xcolor} % For shading in tables
%\usepackage{pdfcolmk} <==== not needed with xelatex
\usepackage{multirow}

%\usepackage{lscape} %to put the long table of dwellings sideways
%\usepackage{wallpaper}
\usepackage{blindtext}
%\usepackage{showframe}

\usepackage{caption} % To change way captions are labelled
\usepackage{pdfpages}
\usepackage{ltablex}
\usepackage{nicefrac} % to write fractions
\usepackage{attrib} % For source of quotations
\usepackage{lettrine} % For NewThought formatting
\usepackage{array} % To define width of columns in long table
\usepackage{booktabs} % Nicer spacing in columns
\usepackage{siunitx} % To write Celsius, etc.
\usepackage{enumitem} % To create item lists

\usepackage{scrextend}
\usepackage{threeparttable} % For table notes + To allow footnote material to stay with the tabular environment
\usepackage{etoolbox} % To make table footnote font smaller
\usepackage{threeparttablex}
\appto\TPTnoteSettings{\footnotesize}
\usepackage{textcomp} % For Numero symbol
%\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{xcolor}
\usepackage[linguistics,edges]{forest}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{titling}
\usepackage{fontspec}
%\setmainfont[Scale=1.0, Ligatures={Common, Rare, TeX}]{Palatino Linotype}

\usepackage{newpxtext} % Font for document instead of obsolete Palatino
\usepackage{fancyhdr}
\usepackage{etoolbox}

\newcommand{\mysplit}[1]{%
    \begin{tabular}[t]{@{}l@{}}   %% remove [t] if you need vertical centered things.
        #1
    \end{tabular}
}

% CHAPTER, SECTION, SUBSECTION STYLE %%%%%%%%%%%%%%%%%%%%%%%%

% DEFINING CHAPTER AND SECTION COLORS %%%%%%%%%%%%%%%%%%%%%%%

\definecolor{green}{HTML}{3f8854}
\definecolor{runeg}{HTML}{3d857c}
\definecolor{blue}{HTML}{3d587e}
\definecolor{runeo}{HTML}{b6732b}
\definecolor{runer}{HTML}{af1824}

% CHAPTER, SECTION, SUBSECTION STYLE %%%%%%%%%%%%%%%%%%%%%%%%

\newfontfamily\headingfont[]{Candara}
\titleformat{\chapter}[display]
{\bfseries\color{runeg}\filcenter\fontsize{35}{35}\headingfont} % Size of Chapter1&Chapter
{\huge\MakeUppercase\headingfont{\chaptertitlename} \thechapter}
{12pt}
{\tikz[remember picture,overlay]\node[inner sep=0pt] at ($(current page.north) +
    (0pt,-117pt)$) {\includegraphics[width=14cm]{chapterHead_10cm}};}
\titlespacing{\chapter}{0pt}{50mm}{42.5mm}
\titleformat*{\section}{\LARGE\color{runer}\headingfont}
\titleformat*{\subsection}{\Large\color{runeo}\headingfont}
\titleformat*{\subsubsection}{\large\color{runeo}\headingfont}
\renewcommand{\maketitlehooka}{\headingfont}

\begin{document}

\ae
\'{\"{u}}
{\~o}
{\'o}
{\`o}
{\"o}
{\^o}
{\'u}
{\`u}
{\'e}
\u{\i}
{\`o}
{\'i}
{\`a}
{\'a}
``
''

\end{document}
  • 1
    you would make it a lot easier for people to debug if you removed all packages not needed to show the issue. Also i assume but you don't say, that you are using xetex not luatex. – David Carlisle Apr 30 at 19:57
  • 3
    you are asking about fontspec but your test document does not load fontspec so naturally you get ! Undefined control sequence. l.66 \newfontfamily as \newfontfamily is a fontspec command. – David Carlisle Apr 30 at 20:00
  • David, you are correct to note that I could have removed all unnecessary packages, but I'm not good enough at LaTex to dare to do that as I don't understand how all packages interact with the others. So I prefer to put everything in in case my troubles come from packages that are poorly used. I've also added a screen capture of the commands I use. – CyanideBaby Apr 30 at 20:09
  • Yes. I had not noticed my messing up the fontspec package! It's now fixed and the code is now compilable... and my question (which I've edited in parts) remains. Hope it makes sense. – CyanideBaby Apr 30 at 20:13
  • 3
    No that is such a bad idea!! never just start with a massive incoherent preamble and then wonder why you get conflicting definitions, always start with an empty preamble and then only add packages if you need them. – David Carlisle Apr 30 at 20:14
2

If you cut down your test document to something more reasonable for this site, then you can easily test loading a palatino clone such as TeX Gyre Pagella.

enter image description here

\documentclass[oneside,twocolumn]{book}

\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella} % Palatino clone
\begin{document}

\ae
\'{\"{u}}
{\~o}
{\'o}
{\`o}
{\"o}
{\^o}
{\'u}
{\`u}
{\'e}
\u{\i}
{\`o}
{\'i}
{\`a}
{\'a}
``
''

\end{document}
  • Thank you. Looks lovely, so why were people telling me to not use fontspec, as in the following message: "You should not try to use legacy 8-bit fonts together with fontspec, which selects modern fonts. It won’t work (although it could be made to if you really wanted). You should remove the packages fontenc, textcomp, intputenc and newpxtext" – CyanideBaby Apr 30 at 20:16
  • I don't know who you are quoting there,but if you want to use legacy 8bit fonts then don't use fontspec (and don't use xetex) if you want to use opentype fonts dont use T1 encoding with fontenc or legacy font packages such as textcomp and newpxtext, – David Carlisle Apr 30 at 20:18
  • Sure. All I know is that I just want my document to look as good as it can, whether it uses legacy 8bit fonts or not -- I had no idea I was using these fonts; in fact I had not idea they even existed. I simply started using fontspec and it seemed to be ok until at least two people on this site told me it was the wrong approach to using fonts. Hence my confusion and my question. – CyanideBaby Apr 30 at 20:25
  • 1
    @CyanideBaby opentype unicode fonts have thousands of characters in each font. classic Tex fonts in OT1 or T1 encoding have at most 127 or 256 characters per font, so the definitions of almost all accents and non ascii characters are necessarily different. If you load (as you show in the question and earlier questions) some packages designed for unicode and some packages designed for 256-character fonts then things will go badly wrong. Exactly what happens depends on what order you load things but nothing that happens will be good. – David Carlisle Apr 30 at 20:30
  • 1
    @CyanideBaby if you mean comments like tex.stackexchange.com/questions/488287/… then read it again it doesn't say not to use fontspec, it says (as I say again here) that if you use fontspec do not use T1 encoding and pdftex font packages like newtxtext – David Carlisle Apr 30 at 20:33

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.