# Font change does not work

As the title says I wanted to change the font of my document with e.g.

\usepackage[T1]{fontenc}
\newcommand{\changefont}[3]{
\fontfamily{#1} \fontseries{#2} \fontshape{#3} \selectfont}
\changefont{phv}{b}{sl}


but it does not work. There is no change. The font stays the same. I tried different ones already.

Here is my code:

\documentclass{book}
\usepackage{geometry}
\geometry{left=4cm,right=3cm, top=2cm, bottom=2cm}
\usepackage[pagestyles]{titlesec}
\titlespacing*{\chapter}{0pt}{-30pt}{20pt}

\titleformat{\section}

\titleformat{\subsection}

\titleformat{\subsubsection}

\titleformat{\paragraph}

\usepackage[T1]{fontenc}
\newcommand{\changefont}[3]{
\fontfamily{#1} \fontseries{#2} \fontshape{#3} \selectfont}
\changefont{phv}{b}{sl}

\usepackage[ngerman]{babel}
\usepackage{mathptmx}
\usepackage{helvet}
\usepackage{wallpaper}
\usepackage{color}
\usepackage[final]{pdfpages}
%,bookmarksopenlevel={1}
\hypersetup{
pdftitle={},
%  pdfauthor={},
pdfsubject={satistics book},
pdfkeywords={},
}

\usepackage{xcolor,bookmark}
\usepackage{scrextend}
\usepackage{titlepic}
\usepackage{shorttoc}
\usepackage{courier}
\usepackage{type1cm}
\usepackage{zref-abspage}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage[bottom]{footmisc}
\usepackage{tocstyle}
\usetocstyle{allwithdot}
%\usepackage{thmbox}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{marginnote}
%\usetocstyle{KOMAlike}
\usepackage{wrapfig}
\usepackage{paralist}
\usepackage{amssymb}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{ulem}
\usepackage{fancyhdr}
%\usepackage{sectsty}
\usepackage{booktabs}
\makeindex
\listfiles

\newmdenv[backgroundcolor=textbeispiel,linecolor=blue,roundcorner=10pt,outerlinewidth=1pt,skipbelow=2pt, skipabove=6pt]{myframedenv}%innerlinecolor=green,innerlinewidth=1pt,middlelinewidth=2pt,middlelinecolor=yellow

\newtheoremstyle{mystyle}
{}{}{}{}%
{\bfseries}{:}{.5em}{}%

\newtheoremstyle{mystyle2}
{}{}{}{}%
{\bfseries}{}{.5em}{}%

\theoremstyle{mystyle}

skipbelow=\topsep]{beispiel}{Beispiel}

\newmdtheoremenv[hidealllines=true,
skipbelow=0pt]{formel}{Formel}

\theoremstyle{mystyle2}

\newmdtheoremenv[hidealllines=true,
backgroundcolor=aufgaben,skipabove=0pt,
skipbelow=0pt]{aufgabe}{Aufgabe}

\newmdtheoremenv[hidealllines=true,
backgroundcolor=loesung,skipabove=0pt,
skipbelow=0pt]{loesung}{L\"osung}

\definecolor{dunkelgruen}{rgb}{0.8,0.87843,0.8}
\definecolor{hellgruen}{rgb}{0.90196,0.941176,0.90196}
\definecolor{aufgaben}{rgb}{0.9333,0.93333,0.933333}

\newpagestyle{mystyle}{
{\color{red} \thesection\ \sectiontitle}{}{\thepage}}

\begin{document}
\frontmatter

\setlength{\marginparwidth}{3cm}
\marginparsep = 0.4cm
\pagestyle{plain}
\pagenumbering{Roman}

\makeatletter
\let\stdl@part\l@part
\renewcommand*{\l@part}[2]{%
\let\stdl@chapter\l@chapter
\renewcommand*{\l@chapter}[2]{%
\makeatother

\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\shorttableofcontents{Inhalts\"ubersicht}{1}
\bookmark[page=15,rellevel=1,keeplevel,view={XYZ},color=red]{Inhalts\"ubersicht}
\bookmark[page=17,rellevel=1,keeplevel,view={XYZ},color=red]{Inhaltsverzeichnis}
\tableofcontents
\clearpage
\pagenumbering{arabic}
%

%\pagestyle{mystyle}
\mainmatter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagestyle{fancy}
\fancyhf{}

%\include{part1}
%\include{chapter1}
%\include{chapter2}
%\include{part2}
%\include{chapter3}
%\include{chapter4}
%\include{chapter5}
%\include{chapter6}
\backmatter

\appendix

\include{appendix}

\listoffigures
\newpage
\listoftables
\backmatter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\include{glossary}
%\include{solutions}
\cleardoublepage
\phantomsection
\printindex

\cleardoublepage
\phantomsection
%\includepdf{author}
%\includepdf{back}
\end{document}


I have given you so much code, because I do not know where my mistake is?

-
Do you really want all the document in Helvetica boldface slanted? –  egreg Sep 5 '12 at 14:32

If you want to typeset everything in Helvetica boldface slanted, then

\renewcommand{\rmdefault}{phv}
\renewcommand{\sfdefault}{phv}
\renewcommand{\mddefault}{b}
\renewcommand{\bfdefault}{b} % Helvetica has no bx series
\renewcommand{\updefault}{sl}


in your preamble will do. I don't think it's a good idea.

-
so what else then? @egreg –  Heronimious Sep 5 '12 at 14:49
@Gerondus I don't understand –  egreg Sep 6 '12 at 10:20

The M stands for minimal.

1. There is already a macro for the font settings:

\usefont{T1}{phv}{b}{sl}

2. Which font do you want to use in the preamble? There is no text to typeset.

You probably want to set the font of the headers. You have to include \usefont inside the header's definition.

In this MWE even your command would work:

\documentclass{book}

\usepackage[T1]{fontenc}

\usepackage{mathptmx}
\usepackage{helvet}

\begin{document}
\usefont{T1}{phv}{b}{sl}
Testing
\end{document}


For changes in the header do include \changefont/\usefont inside its definition, e.g.,

\usepackage[pagestyles]{titlesec}

\titleformat{\section}
{\usefont{T1}{phv}{b}{n}\Large\bfseries}{\thesection}{1em}{}


To change the body text font use something like:

\renewcommand*{\rmdefault}{phv}


(but Helvetica is used automatically because of \usepackage{helvet}.)

-
Not only the font of the headers, also the font of the normal text! The complete text in the document. –  Heronimious Sep 5 '12 at 14:27
@Gerondus I updated my answer. Maybe you should state what font(s) you want to use where. –  Qrrbrbirlbel Sep 5 '12 at 14:37
Well, first: BIG THANKS, BUT: Actually I just want my document text to look scientific, so I do not want to use helvetica, it was just to test it. So could you give me an all-in-one solution which works with a scientific font for the text in the document? Thanks a lot! @Qrrbrbirlbel –  Heronimious Sep 5 '12 at 14:43
@Gerondus -- You need to tell the people trying to help you what 'scientific' font(s) you actually want to use, especially if you are hoping for an 'all-in-one solution'. There are relatively easy ways to have different fonts used in your headers/footers, sectional headings, etc. And it is unlikely that a 'scientific' document should be changing fonts so often in the main body that a \changefont command is really needed (though I suppose anything is possible). –  jon Sep 5 '12 at 14:58
I just want to change the overall font to another font then this standard latex font. Thats all I want, so I think palatino is ok? So how can I change the font of my standard text to palatino @jon –  Heronimious Sep 5 '12 at 15:26