Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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{\chapter}[display]{\color{headercolor}\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}

\titleformat{\section}
{\color{headercolor}\normalfont\Large\bfseries}{\thesection}{1em}{}

\titleformat{\subsection}
{\color{headercolor}\normalfont\Large\bfseries}{\thesubsection}{1em}{}

\titleformat{\subsubsection}
{\color{headercolor}\normalfont\large\bfseries}{\thesubsubsection}{1em}{}

\titleformat{\paragraph}
{\color{headercolor}\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}

\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}
%\usepackage[hidelinks,bookmarks=true,bookmarksopen=true,bookmarksnumbered=true,colorlinks=true,linkcolor=black,]{hyperref}
\usepackage[hidelinks,bookmarksopen=false,
hypertexnames=TRUE,pdfpagelabels=true]{hyperref}[2011/02/05]%colorlinks,linkcolor=black,
\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{shadethm}
\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}

\newmdtheoremenv[hidealllines=true,backgroundcolor=shadethmcolor,skipabove=\topsep,
skipbelow=\topsep]{beispiel}{Beispiel}

\newmdtheoremenv[hidealllines=true,
backgroundcolor=shadethmcolor2,skipabove=0pt,
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}
\definecolor{headercolor}{rgb}{0.6941,0.6745,0.4863}

\newpagestyle{mystyle}{
\headrule \sethead[\thepage][][\color{red} \chaptertitlename\ \thechapter. \chaptertitle]
{\color{red} \thesection\ \sectiontitle}{}{\thepage}}

\setlength{\headheight}{24pt}%

\begin{document}
\frontmatter

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

\makeatletter
\let\stdl@part\l@part
\renewcommand*{\l@part}[2]{%
  \stdl@part{\textcolor{headercolor}{#1}}{\textcolor{headercolor}{#2}}}
\let\stdl@chapter\l@chapter
\renewcommand*{\l@chapter}[2]{%
  \stdl@chapter{\textcolor{headercolor}{#1}}{\textcolor{headercolor}{#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{}
%\fancyhead[L]{\parbox{0.7\textwidth}{\textbf{ \textcolor{headercolor}\leftmark\textcolor{headercolor}{\rightmark}}}}
%\fancyhead[L]{ \textcolor{headercolor}{\rightmark}}%\thesection%\textcolor{headercolor}\text{ }\leftmark \text{ }


\fancyhead[L]{\hspace{2mm}\textcolor{headercolor}{\leftmark}\text{ }\textcolor{headercolor}{\rightmark}\hfill\textcolor{headercolor}{\thepage}\hspace{4mm}}
\renewcommand{\headrule}{\vspace{-\headheight}\textcolor{headercolor}{\vrule height \headheight width 2pt\relax\rule{\textwidth-8pt}{2pt}\vrule height \headheight width 2pt\relax}}

%\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
\addcontentsline{toc}{part}{Index}
\printindex

\cleardoublepage
\phantomsection
\addcontentsline{toc}{part}{the author}
%\includepdf{author}
%\includepdf{back}
\end{document}

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

share|improve this question
2  
Do you really want all the document in Helvetica boldface slanted? –  egreg Sep 5 '12 at 14:32

2 Answers 2

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.

share|improve this answer
    
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}.)

share|improve this answer
    
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
1  
@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
1  
@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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.