3

I am trying to use \fontfamily command to insert specific kinds of fonts for specific contents in my document. Also, using the command \renewcommand{\ttdefault}{<Font Name>} does not seem to work either. The commands are relatively simple and I basically just want to change font families. Could this be due to compatibility issues with some of my packages?

Here is a sample of what I get:

enter image description here

My source code:

\documentclass[12pt]{book}

    % !TeX program = xelatex

    \usepackage[T1]{fontenc}



    \usepackage{fontspec}   

    \setmainfont{TeX Gyre Adventor}
    \newcommand*{\myfont}{\fontfamily{Courier}\selectfont}
    \renewcommand{\ttdefault}{Courier}


    \usepackage{amsmath}

    \usepackage{amssymb, amsfonts}

    \usepackage[Omega]{gensymb}
    \usepackage[]{mathtools}

    \usepackage{cuted}



    \usepackage[thicklines]{cancel}

    \usepackage{float}


    \usepackage[]{rotating}
    \usepackage{subfloat}

    \usepackage{cleveref}

    \usepackage{ragged2e}

    \usepackage{tabularx}


        \usepackage{multirow}

        \usepackage[flushleft]{threeparttable}

    \usepackage{colortbl}
    \usepackage{comment}
    \usepackage{pifont}

    \usepackage[pointedenum]{paralist}


    \usepackage[autostyle, english = american]{csquotes}
    \usepackage{embrac}

    \usepackage[perpage, multiple, stable]{footmisc}




    \usepackage{marginnote}

    \usepackage[svgnames]{xcolor}

    \usepackage{soul}

    \usepackage[normalem]{ulem}

    \usepackage{blindtext}

    \usepackage{environ}

    \usepackage{bigfoot}
    \usepackage[]{matlab-prettifier}

    \newcommand*\pct{\scalebox{0.7}{\hspace{0.5mm}$\%$}}
    \newcommand*\note{\scalebox{0.35}{$0$}}

    \setcounter{chapter}{1}


    \usepackage[nodayofweek]{datetime}

        \renewcommand{\timeseparator}{:}    
        \renewcommand{\amname}{ AM}
        \renewcommand{\pmname}{ PM}
        \settimeformat{ampmtime}
        \renewcommand{\dateseparator}{/}    
        \newdateformat{usvardate}{\monthname[\THEMONTH] \ordinaldate{\THEDAY}, \THEYEAR}
        \usvardate



\begin{document}

\centering \section*{ECE 331 - Exam 1 Pitfall Notes}

\textbf{\today \mbox{ }- \currenttime}

\justify


\texttt{Note that typewriter command $\backslash$texttt does not really change the font}

{\myfont This text is also supposed to be in Courier format}

OK guys. In what follows, I will provide you with a some notes about your pitfalls, why they are pitfalls and how to avoid or rectify them.


\paragraph{Area Conversion.} I \strong{noted that many} of you make mistakes when converting from $cm^{2}$ to $m^{2}$. When doing  conversion of areas from one unit to another, the original unit is scaled \emph{twice}. Hence, converting from $cm^{2}$ to $m^{2}$ requires that you divide over $100$ two times. For instance, $30 \thickspace cm^{2} = \frac{30}{100\times100} \thickspace m^{2} \Rightarrow 30 \thickspace cm^{2} =  0.003 \thickspace m^{2}$.







\paragraph{Neglecting Air Gap in Iron Cores.} The relative permeability of iron can be thousands of times that of air ($\mu_{r} = 2000-100,000$), which means that the reluctance of the air gap $\displaystyle \mathcal{R}_{g} = \frac{l_{g}}{\mu_{\note} A_{g}}$ would be much more than the reluctance of the core $\displaystyle \mathcal{R}_{c} = \frac{l_{c}}{\mu_{r}\mu_{\note} A_{c}}$. Hence, significant error would definitely result in if you did not take into account the air gap in magnetic~circuits.



\vfill

\textit{\Large All the best,}

\vspace{2mm}

\emph{\Large Al-Motasem Aldaoudeyeh}

\end{document}

1 Answers1

6

You can't use arbitrary names as fontfamily. They must be declared first. With fontspec you can do it with NFSSFamily, but can also simply define new font families.

\documentclass[12pt]{book}

   \usepackage{fontspec}

   \setmainfont{TeX Gyre Adventor}
   \setmonofont{TeX Gyre Cursor} 
   \newfontfamily\verbatimfont{DejaVu Sans Mono}[NFSSFamily=dejamono]


\begin{document}

standard text

{\ttfamily courier}

{\fontfamily{dejamono}\selectfont DejaVu Sans Mono} is then equivalent to 
{\verbatimfont DejaVu}
\end{document}

enter image description here

Ulrike Fischer
  • 327,261