9

I have defined fontsize, and even with your answered question help I solved the situation in this way:

\usepackage{titlesec}

\titleformat{\chapter}

       {\normalfont\fontfamily{phv}\fontsize{16}{19}\bfseries}{\thechapter}{1em}{}

\titleformat{\section}

       {\normalfont\fontfamily{phv}\fontsize{12}{17}\bfseries}{\thesection}{1em}{}

\titleformat{\subsection}

       {\normalfont\fontfamily{phv}\fontsize{12}{17}\bfseries}{\thesubsection}{1em}{}

Now i have to add only to the subsection an italic style .How can I do?? Thank you so much for your attention and your precious help!

2
  • Please always post a complete Minimal (non-)Working Example demonstrating the issue. That at least means adding \documentclass..., \begin{document}... \end{document} etc. That said, just add \itshape after \bfseries to the format for \subsection.
    – cfr
    Commented Mar 16, 2014 at 19:25
  • 2
    Welcome to TeX.SE!
    – Mico
    Commented Mar 16, 2014 at 19:32

2 Answers 2

11
\usepackage{titlesec}

\titleformat{\chapter}    
       {\normalfont\fontfamily{phv}\fontsize{16}{19}\bfseries}{\thechapter}{1em}{}

\titleformat{\section}    
       {\normalfont\fontfamily{phv}\fontsize{12}{17}\bfseries}{\thesection}{1em}{}

\titleformat{\subsection}    
       {\normalfont\fontfamily{phv}\fontsize{12}{17}\bfseries\itshape}{\thesubsection}{1em}{}

For example:

\documentclass{book}
\usepackage{titlesec}

\titleformat{\chapter}
       {\normalfont\fontfamily{phv}\fontsize{16}{19}\bfseries}{\thechapter}{1em}{}

\titleformat{\section}
       {\normalfont\fontfamily{phv}\fontsize{12}{17}\bfseries}{\thesection}{1em}{}

\titleformat{\subsection}
       {\normalfont\fontfamily{phv}\fontsize{12}{17}\bfseries\itshape}{\thesubsection}{1em}{}


\begin{document}

\chapter{Chapter}
\section{Section}
\subsection{Subsection}

\end{document}

Section formatting

Note that an oblique font is substituted for italic as no italic shape is available for this family.

1
  • @egreg Ah, true. Of course, it obviously wouldn't compile anyway.
    – cfr
    Commented Mar 16, 2014 at 22:01
2

You should avoid explicit \fontfamily instructions as long as possible. You're better declaring a sans serif font and then use \sffamily; for slanted type, add \slshape. If you use Helvetica for titles, you should use it in every case a sans serif font is requested in the document.

\documentclass{book}
\usepackage{helvet}
\usepackage{titlesec}

\titleformat{\chapter}
  {\normalfont\fontsize{16}{19}\sffamily\bfseries}
  {\thechapter}
  {1em}
  {}

\titleformat{\section}
  {\normalfont\fontsize{12}{17}\sffamily\bfseries}
  {\thesection}
  {1em}
  {}

\titleformat{\subsection}
  {\normalfont\fontsize{12}{17}\sffamily\bfseries\slshape}
  {\thesubsection}
  {1em}
  {}

\begin{document}
\chapter{Something}
\section{Title}
\subsection{Again}
\end{document}

Note that the code, as you formatted it, doesn't compile. I prefer this layout for the \titleformat command, that clearly shows the various arguments.

enter image description here

2
  • Could you please explain why one should avoid explicit \fontfamily instructions as long as possible. Commented Mar 17, 2014 at 0:00
  • 1
    @GonzaloMedina This ensures better independence of the document's code from things that might change. Instead of Helvetica one might prefer TeX Gyre Heros and this could be obtained by just modifying \usepackage{helvet} into \usepackage{tgheros}. Also a scaled option can be given (to both packages).
    – egreg
    Commented Mar 17, 2014 at 0:06

You must log in to answer this question.

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