2

There are several questions posted here on fonts in latex, but for many of them, one has to use several commands.

But there are also some simple commands to change fonts, such as:

\sffamily, \rmfamily, \ttfamily 

Can I get to know some more such commands for different fonts? Usually, I had seen different answers for such questions on fonts, but as soon as see so many commands there and copy-paste it, then some errors usually comes, and then I think like this: "lets remove this command and see what happens" It was difficult to understand also what a command does there?

So I thought there could be simple commands to change fonts.

For example, this is typing in a book, I don't know which is this font:

enter image description here

The following two are other examples which came as output in my typing

 \documentclass[a4paper,12pt]{article}
 \usepackage[utf8]{inputenc}
 \usepackage{tgbonum}

 \begin{center} 
 {\Large 1.3    Relations with Lie groups} 
 \end{center}
 We discuss only the beginning of this topic. First we look at the ....

 \ttfamily
 \begin{center} 
 {\Large 1.3    Relations with Lie groups} \end{center}
 We discuss only the beginning of this topic. First we look at the  ....

enter image description here

2
  • 1
    As it stands I'm not really sure what you are after: one can set \sffamily, etc. using the LaTeX font selection scheme to whatever, depending on the font in use. Can you give a bit more detail?
    – Joseph Wright
    Jan 5, 2017 at 9:05
  • 1
    No! You should not have any font commands there, nor size commnds like \large nor center environment nor explicit numbers like 1.3 just use \section{Relations with Lie groups} and the style and numbering is automatic and can be configured in the preamble or your document class. Jan 5, 2017 at 11:13

3 Answers 3

2

The LaTeX2e font switching commands come in three broad groups: \xxfamily, \yyseries, and \zzshape, where xx, yy, and zz represent two-letter

Combinations are allowed across family/series/shape groups. Assuming the font family you're interested in provides lots of possible combinations, you could write things such as

{\ttfamily\bfseries\slshape Hello World}

or

{\rmfamily\bfseries\itshape Goodbye World}

Some font packages, e.g., lmodern, may feature most of the possible combinations of family, series, and shape attributes; however, other fonts may be more restrictive. In fact, most packages in general provide only a few of all possible combinations.

1

Maybe you want to play around with different fonts, which happen to be installed yt your local system, in order to find that font, you are most pleased with?

In that case, you should define the above textblock to be an command, on order to save typing labour and have the same text over and over again:

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{luainputenc}

\newcommand{\myblindtext}{%
  \begin{center}%
    {\bfseries\Large 1.3    Relations with Lie groups} %
  \end{center}%
  We discuss only the beginning of this topic. First we look at the \dots\par}%

\begin{document}
\rmfamily\myblindtext
\sffamily\myblindtext
\ttfamily\myblindtext
\end{document}
0

You have an example where you do \usepackage{tgbonum}. That is an easy way to set fonts, to use a package that changes fonts for you, so with "simple commands to change fonts" I assume that is what you primarily want.

You'll find several such packages listed at http://www.ctan.org/tex-archive/fonts/ .Many such packages change several fonts for you at once, to get a main font and a sanserif font that go well together, for example. Here are a few such packages:

  • libertine (use "Linux Libertine")
  • lmodern (use "Latin Modern")
  • newtx (use TX fonts that look like Times)

Often you will only use one or a couple of such packages in the beginning. As an example I have used

\usepackage[osf,semibold]{libertine}
\usepackage[scaled=0.804]{beramono}
\usepackage[libertine]{newtxmath}

when using Linux Libertine with friends by choosing three packages for text font, monospace font and math font.You can sometimes get suggestions on what to combine it with from the documentation for the package for the main font. For many documents you'll almost never use commands like \ttfamily. You'll rather get monospace text because you use a command or environment that sets that, for example something verbatim.

My suggestion is to focus on what you want to use as the main font of your document, and see if there is a package for that, and then consult the documentation for that package for more information to see if it changes other fonts as well. The package "tgbonum" that you mentioned for example only changes the default font of a document, so you might want to complement that with something else.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .