2

I want to change the style (fonts spacing etc.) of Title of paper and the sections of my paper written in article class. How can I change.

  • There are so many options to change this. I think it would be better if you could be more specific. Provide the community with some sample code, making specific requests in terms of the expected output. – Werner Feb 27 '15 at 6:22
  • Thanks for Reply. Actually, I want to change the fonts (kpfonts) only for the title of my paper which occurs in the starting, and same with the section heads and rest of the paper will be in rm. I am using the article class. – satishmathematics Feb 27 '15 at 6:24
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – karlkoeller Feb 27 '15 at 6:28
  • @satishmathematics: So you are using kpfonts.sty? Shall only the in-text section headings appear or in ToC as well? – user31729 Feb 27 '15 at 6:34
  • Thanks.No, in only text section heading, section no. and in the title of the paper. – satishmathematics Feb 27 '15 at 10:07
1

This redefines the \section command (using xparse facilities) and grabs the third argument (the section title), injects a font change command and restores the font afterwards. The ToC entry is still done in normal font (unless explicitly done in #2 or in the section title itself)

The kpfonts use the jkp basename for the font family, see the manual for the various options to use other names (and families).

The font change is done within the command \SectionHeadingFont and can be altered there. I chose the bx series, upright fontshape, but no additional scaling.

In my opinion the section number font should be changed to the same as the heading font.

Within the section title and the document title, I made explicit changes back to normal settings, in order to show the difference.

\documentclass{article}


\usepackage{xparse}
\usepackage{xpatch}
\usepackage{blindtext}



\let\LaTeXStandardSection\section%

\NewDocumentCommand{\SectionHeadingFont}{m}{%
  \fontfamily{jkpx}\fontseries{bx}\fontshape{n}\selectfont#1\normalfont%
}%

\NewDocumentCommand{\TitlePageFont}{}{%
  \fontfamily{jkpx}\fontseries{bx}\fontshape{n}\selectfont%
}%


\xpretocmd{\maketitle}{\TitlePageFont}{}{}
\xapptocmd{\maketitle}{\normalfont}{}




\RenewDocumentCommand{\section}{som}{%
  \let\LaTeXStandardTheSection\thesection% 
  % Redefine the section number formatting
  \renewcommand{\thesection}{\SectionHeadingFont{\arabic{section}}}% 
  \IfBooleanTF{#1}{%
    \LaTeXStandardSection*{#3}%
  }{%
    \IfValueTF{#2}{%
      \LaTeXStandardSection[#2]{\SectionHeadingFont{#3}}%
    }{%
      \LaTeXStandardSection[#3]{\SectionHeadingFont{#3}}%
    }%
  }%
  \renewcommand{\thesection}{\LaTeXStandardTheSection}%
}


\author{A.N. Author}
\title{How to use different fonts in \LaTeXe \normalfont\\ \bfseries How to use different fonts in \LaTeXe}


\begin{document}
\maketitle
\tableofcontents

% Compare in output
\section{First\normalfont\bfseries First}

\blindtext


\end{document}

enter image description here

| improve this answer | |
  • My Dear, Thanks a lot for your guidance. It solves my problem. Thanks again. – satishmathematics Feb 27 '15 at 12:45
  • 1
    @satishmathematics Don't forget that you can accept Christian's answer by clicking the checkmark to its left. In case of doubt, please see How do you accept an answer? – Gonzalo Medina Feb 27 '15 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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