4

Having this MWE:

\documentclass{book}

\usepackage[explicit]{titlesec}

\titleformat{\chapter}[block]{\filcenter}{}{0pt}{\MakeUppercase{#1}}

\begin{document}
\chapter*{This should be all Uppercase.  "This text should remain as it is"}
\end{document}

Which command could one use to have the text "This text should remain as it is" not affected by the titlesec uppercase definition (see image)?

enter image description here

Edit: Fixed \titleformat's arguments, as per Gonzalo Medina's remark (see below).

gsl
  • 699

2 Answers2

4

Another option would be to load the textcase package and use \MakeTextUppercase instead of \MakeUppercase for the title formatting (this, in any case, is a good idea to prevent issues with possible \labels and math expressions inside titles); now you can use \NoCaseChange to preserve the case of the desired text:

\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{textcase}

\titleformat{\chapter}[block] {\filcenter\MakeTextUppercase{#1}}{}{}{}

\begin{document}

\chapter*{This should be all Uppercase. \NoCaseChange{This text should remain as it is}}

\end{document}

The result:

enter image description here

Remark

Your current definition of \titleformat is faulty; the fourth mandatory argument cannot be empty, so I'd suggest you to change it to something like

\titleformat{\chapter}[block]
  {\filcenter}{}{0pt}{\MakeTextUppercase{#1}}

(notice that no provision was made regarding the counters so \chapter will produce unnumbered chapters)

Gonzalo Medina
  • 505,128
  • Thank you, that is what I was looking for, a command like \NoCaseChange. Thanks. – gsl Feb 04 '15 at 07:40
  • May I know what the line \DeclareRobustCommand{\shouldremain}{} does? Your answer works even without it. Would you know why using the normal (no star) version, \chapter{This should be all Uppercase. \NoCaseChange{"This text should remain as it is"}}, seems to throw an error? Chapter 1. ./macro.tex:18: Missing number, treated as zero. <to be read again> – gsl Feb 04 '15 at 08:47
  • @gsl I'm on my mobile now, so writing code is painful. Later I'll provide a proper answer. For now, the line you mentioned is superfluous, and can be safely deleted. The error is due to the fact that your \titleformat definition is wrong (the fourth argument cannot be empty). As I said, later I'll write a proper answer. – Gonzalo Medina Feb 04 '15 at 13:36
  • @gsl I've updated my answer. – Gonzalo Medina Feb 04 '15 at 16:24
1

For the ad-hoc usage you can define a robust command that contains the fixed-text:

enter image description here

\documentclass{book}

\usepackage[explicit]{titlesec}

\titleformat{\chapter}[block]{\centering {\MakeUppercase {#1}}} {} {} {} %

\begin{document}

\DeclareRobustCommand{\shouldremain}{This text should remain as it is}
\chapter*{This should be all Uppercase. \shouldremain}

\end{document}

If you're using biblatex, you can also use

\usepackage{biblatex}
%...
\chapter*{This should be all Uppercase. \MakeSentenceCase{This text should remain as it is}}
Werner
  • 603,163