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.

I'm interested in setting the titles of section and more in lowercase small caps. And I don't know how to automatically achieve this.

\documentclass{scrartcl}
\setkomafont{sectioning}{\scshape}
\usepackage{hyperref}
\begin{document}
    \section{Hello}
    \section{hello}
    \subsection{helloHello}
\end{document}

But if I write everything in lowercase, then the \tableofcontents doesn't look good unless I use small caps there too. I know about \MakeLowercase{} but this needs an argument.

By the way, as I noted, I just want to show them in lowercase small caps in the document, not in the table of contents, ….

Any ideas?

PS: I don't know if this is necessary, but I'm using the MinionPro package.

EDIT: after some research, apart from what is answered here, in classicthesis.sty you can look at other different (or semi-different) method.

share|improve this question

4 Answers 4

up vote 4 down vote accepted

At his homepage, Markus Kohm, the author of KOMA-script, has code for majuscle in section headings.

I have slightly adapted the code from Versalien in \section und \subsection?)

\documentclass[11pt]{scrartcl}

\usepackage[UKenglish]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{MinionPro}
\renewcommand{\scdefault}{ssc} % MinionPro's spaced small caps as standard

\makeatletter
\newcommand*{\Section}{}
\let\Section\section
\renewcommand*{\section}{%
  \@ifstar {\star@section}{\@dblarg\nonstar@section}%
}
\newcommand*{\star@section}[1]{%
  \Section*{\MakeLowercase{#1}}%
}
\newcommand*{\nonstar@section}[2][]{%
  \Section[{#1}]{\MakeLowercase{#2}}%
}
\let\Subsection\subsection
\renewcommand*{\subsection}{%
  \@ifstar {\star@subsection}{\@dblarg\nonstar@subsection}%
}
\newcommand*{\star@subsection}[1]{%
  \Subsection*{\MakeLowercase{#1}}%
}
\newcommand*{\nonstar@subsection}[2][]{%
  \Subsection[{#1}]{\MakeLowercase{#2}}%
}

\setkomafont{disposition}{\normalcolor\scshape}

\usepackage{hyperref}

\begin{document}
\tableofcontents
\section{Heading level 1}
\subsection{Heading level 2}

\end{document}

This solution works with starred sections. And it is easy to add more formatting by using the normal:

\setkomafont{level}{command}
\addtokomafont{level}{command}

I will also suggest that you use the package textcase to make the case changes more fool proof:

\usepackage[overload]{textcase}
share|improve this answer
    
I like this option much more than the others, because I don't need to use another package. At first sight, it works for me. I will do a bit more of trying and also wait to see if anyone points something about this. If not, I think this is the final answer (to me). –  Manuel Feb 21 '13 at 21:55
    
@Manuel: Well, sveinung links to the source of inspiration, but forgot to add, that the original solution is from Markus Kohm, the KOMA-Script developer, himself. –  Speravir Feb 21 '13 at 23:05
    
@Speravir Sorry, it was not my intention not to give Markus Kohm credit. I was in a hurry. I have corrected the reference. –  Sveinung Feb 22 '13 at 8:00
    
No problem, Sveinung. I added the remark also in reaction of Manuel’s statement “… because I don’t need to use another package”. –  Speravir Feb 22 '13 at 17:00
    
Then I really like this answer. Ah, the name of the package is \usepackage{MinionPro} instead of \usepackage{minionpro} for the sake of correctness. –  Manuel Feb 22 '13 at 20:55

A patch that seems to do what you want is as follows. It will apply to all sectional units, though.

The hyperref package must be loaded after the patches have been applied.

\documentclass{scrartcl}
\usepackage[rm=oldstyle]{cfr-lm} % for oldstyle figures
\usepackage{microtype}

\usepackage{xpatch}
\makeatletter
% patch the relevant commands to enclose the section title as argument to a command
\xpatchcmd{\@sect}{#8\@@par}{\lowsmallcaps{#8}\@@par}{}{}
\xpatchcmd{\@ssect}{#5\@@par}{\lowsmallcaps{#5}\@@par}{}{}
\makeatother

% \usepackage{hyperref} % Must go after the patches

\setkomafont{disposition}{\normalfont\scshape} % use small caps for section titles
\setkomafont{sectionentry}{\normalfont} % use normal font in the TOC

% make everything lower case in section titles
\newcommand\lowsmallcaps[1]{\textls{\MakeLowercase{#1}}}

\begin{document}
\tableofcontents
\section{A section With Mixed Case}

\subsection{This is small caps}

\end{document}

enter image description here


A different way, inspired by Sveinung's answer, is to redefine the commands; be careful that some other package didn't redefine them, because this could cause conflicts.

\documentclass{article}
\usepackage{xparse}
\usepackage{textcase,color}

\ExplSyntaxOn
\NewDocumentCommand{\changesectionalcommand}{mm}
 {
  \cs_new_eq:cN { csc_\cs_to_str:N #1 } #1
  \RenewDocumentCommand{#1}{som}
   {
    \IfBooleanTF{##1}
     {
      \IfValueT{##2}{ \use:c { phantomsection } }
      \use:c { csc_\cs_to_str:N #1 } * { #2 { ##3 } }
      \IfValueT{##2}{ \addcontentsline{toc}{\cs_to_str:N #1}{##2} }
     }
     {
      \IfNoValueTF{##2}
       {
        \use:c { csc_\cs_to_str:N #1 } [ ##3 ] { #2 { ##3 } }
       }
       {
        \use:c { csc_\cs_to_str:N #1 } [ ##2 ] { #2 { ##3 } }
       }
     }
   }
 }

\NewDocumentCommand{\changesectionnumber}{mm}
 {
  \cs_set:cpn { @seccntformat@\cs_to_str:N #1 } { #2 }
 }
\ExplSyntaxOff
\makeatletter
\renewcommand{\@seccntformat}[1]{%
  \@nameuse{@seccntformat@#1}\csname the#1\endcsname\quad}%
}    

\usepackage{hyperref}
\usepackage{lipsum}


\changesectionalcommand{\section}{\MakeTextUppercase}
\changesectionalcommand{\subsection}{\textcolor{red}}

\begin{document}
\tableofcontents

\section{Mixed Case}
\lipsum[2]
\subsection{Red title}
\lipsum[2]

\section[Bar]{Foo}
\lipsum[2]

\section*{Foo foo}
\lipsum[2]

\section*[Bar bar]{Foo foo foo}
\lipsum[2]

\end{document}

A feature of this redefinition is that \section*[<toc entry>]{Title} is allowed, which will automatically perform the \addcontentsline instruction. Of course, one would usually type \section*[Title]{Title}.

The syntax is

\changesectionalcommand{\seccommand}{\macro}

where \macro receives an argument and \seccommand is one of the known sectional commands (from \part to \subparagraph).

For instance, to have sections in spaced lowercase small caps, one can say

\changesectionalcommand{\section}{\lowsmallcaps}
\newcommand{\lowsmallcaps}[1]{\normalfont\scshape\textls{\MakeTextLowercase{#1}}}

(for \textls, microtype is needed).

However, also a corresponding change to the way the section number is typeset is needed, so a complement has been defined and the complete code would have also

\changesectionnumber{\section}{\normalfont}

or the section number would still be boldface, as usual.

enter image description here

share|improve this answer
    
Mmm, hyperref seems to make problems (sorry, but I didn't know that before), and this doesn't work. –  Manuel Feb 21 '13 at 18:46
2  
@Manuel: Another incentive to create a minimal working example that duplicates your current setup. hyperref is important in this case, since hyperlinks are linked with sectional units, citations, table of contents and more... –  Werner Feb 21 '13 at 18:57
    
@Werner I updated my original post. I don't really know what more can affect. But as I said, I didn't thought that this could alter the final result. Do you think I should list all my packages (just to make sure I don't miss something)? –  Manuel Feb 21 '13 at 19:30
    
@Manuel: You should just list packages that affect the sectional headers and the ToC (this was done by means of showing you use a KOMA-script class). hyperref is a good addition. If you're using tocloft or sectsty, then include those as well. If not, don't worry. That's what comments to posts are also for; correction of updated material... –  Werner Feb 21 '13 at 19:33
    
@Werner No, i'm not using those. May be \usepackage[spanish, es-noindentfirst, es-nosectiondot]{babel} affects. I will update the question. –  Manuel Feb 21 '13 at 19:34

Here's an option using the titlesec package:

\documentclass{scrartcl}
\usepackage[spanish, es-noindentfirst, es-nosectiondot]{babel}
\usepackage[explicit]{titlesec}
\usepackage{textcase}
\usepackage{microtype}
\usepackage[colorlinks]{hyperref}

\titleformat{\section}
  {\normalfont\Large\scshape}{\large\thesection}{0.7em}{\textls{\MakeTextLowercase{#1}}}
\titleformat{\subsection}
  {\normalfont\large\scshape}{\small\thesubsection}{0.7em}  {\textls{\MakeTextLowercase{#1}}}

\begin{document}

\tableofcontents
\section{Una Secci\'on de Prueba}
\subsection{Una Subsecci\'on de Prueba}

\end{document}

enter image description here

The \MakeTextLowercase command from the textcase package was used since, unlike standard \MakeUppercase, it doesn't change the case of any math­e­mat­ics, or the ar­gu­ments of \cite, \la­bel and \ref com­mands within the ar­gu­ment.

However, care should be taken with this approach (See Incompatibilities between KOMA-Script and titlesec).

share|improve this answer

Here's a solution that uses the sectsty package:

enter image description here

\documentclass{scrartcl}
\usepackage{sectsty}
\allsectionsfont{\mdseries\scshape\lowercase}
\usepackage[colorlinks=true]{hyperref}
\begin{document}
\tableofcontents
\section{Hello}
\section{Anyone Home?}
\subsection{Hello Hello}
\end{document}

Note that the defaults of the KOMA-Script document with regard to listing section-level headers (sans-serif font, bold) and subsection-level headers (serif font, non-bold) are preserved. If I understand your specifications, this is something that you want.

share|improve this answer
    
But this doesn't make the letters lowercase. –  Manuel Feb 23 '13 at 17:30
    
@Manuel - fixed by adding the \lowercase instruction to the argument of \allsectionsfont. –  Mico Feb 23 '13 at 17:38
    
I don't know, but if I add the MinionPro package, the font of the headers stays Computer Modern… EDIT: the same if I load any font, utopia, charter, palatino, etc. –  Manuel Feb 23 '13 at 17:45
    
@Manuel -- I'm afraid I don't have access to the MinionPro package and therefore can't tell you what might be going on there. Are you loading the MinionPro package before or after the sectsty package? –  Mico Feb 23 '13 at 18:01
    
Doesn't matter. mathpazo package, mathdesign package, garamondx package, also don't work. –  Manuel Feb 23 '13 at 18:03

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.