2
  • I want to auto turn only the first letter of chapter, section and subsection into uppercase.

Can this solve that?

\usepackage{titlesec}
\titleformat{\section}
  {\normalfont\scshape}{\thesection}{1em}{}
  • Second point: How can I put the first letter of a paragraph in bold uppercase?

Edit: found \makefirstuc from package mfirstuc how can i use it in a macro? like above

10
  • 2
    Rather than plain uppercase, you could use the lettrine package to enhance your presentation of the firs letter of each paragraph / chapter / section / subsection.
    – Clément
    Commented Nov 22, 2015 at 17:52
  • not sure what letterine does but i am not looking for an exgerated design and big font
    – Cfun
    Commented Nov 22, 2015 at 17:53
  • by the way any suggestions to well tag this question?
    – Cfun
    Commented Nov 22, 2015 at 17:54
  • 1
    Do you mean the first letter of the section heading or (as lettrine would do) the first letter of the content of the section. either way why not just enter it as uppercase in the source? Commented Nov 22, 2015 at 18:31
  • sometimes i forget to do it so i want to put some macros to do that auto for me to be sure
    – Cfun
    Commented Nov 22, 2015 at 18:36

1 Answer 1

1

You might do like the following:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{mfirstuc}
\usepackage{titlesec}

\titleformat{\section}
  {\normalfont\scshape}
  {\thesection}
  {1em}
  {\makefirstuc}

\begin{document}

\section{Capital}

\section{capital}

%\section{équipe}

\end{document}

but, as soon as the third \section command is uncommented, you'll get an error. Not when you use XeLaTeX or LuaLaTeX, though.

In case you need accented letters in pdflatex, you could do in a more complicated fashion:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage{xparse}

\titleformat{\section}
  {\normalfont\scshape}
  {\thesection}
  {1em}
  {}

\let\originalsection\section
\makeatletter
\RenewDocumentCommand{\section}{som}{%
  \protected@edef\section@opt{\MakeFirstUppercase#2\MakeFirstUppercase}%
  \protected@edef\section@mand{\MakeFirstUppercase#3\MakeFirstUppercase}%
  \IfBooleanTF{#1}
    {\originalsection*{\section@mand}}
    {\IfNoValueTF{#2}
      {\originalsection{\section@mand}}
      {\originalsection[\section@opt]{\section@mand}}%
    }%
}
\protected\def\MakeFirstUppercase#1#2\MakeFirstUppercase{%
  \ifx#1\IeC
    \MakeUppercase#2%
  \else
    \MakeUppercase#1#2%
  \fi
}
\makeatother


\begin{document}

\section{Capital}

\section{capital}

\section{équipe}

\section{Équipe}

\end{document}

enter image description here

All in all, it's much better to rely on correct typing.

6
  • 1
    The error could be circumvented by using a UTF-8 engine, as é is a single token there. Commented Nov 22, 2015 at 20:57
  • why when i remove {\normalfont\scshape} i get another error in fact i only want to turn uppercase i dont want to change fontsize it was only a bad example from me to explain
    – Cfun
    Commented Nov 22, 2015 at 21:06
  • @guest00 You can replace {\normalfont\scshape} with {} or {\normalfont\large} or whatever. If you remove all of it (don't even leave {}), then you aren't passing the correct number of arguments, so you'll get an error.
    – cfr
    Commented Nov 22, 2015 at 21:10
  • @guest00 Sorry, but I answered your question.
    – egreg
    Commented Nov 22, 2015 at 21:10
  • thanks egreg even it's too complicated, @crf when i remove and let only {} it seems that the font change not like the one when i use section without any modification
    – Cfun
    Commented Nov 22, 2015 at 21:20

You must log in to answer this question.

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