1

When I customise the \chapter format using titlesec as follows (important bit is the \bfseries for small caps):

\titleformat{\chapter}[block]
    {\titlerule[1pt]\addvspace{0pt}\Large\scshape\bfseries\centering}
    {\thesection\enspace}{0pt}{}[\vspace{2pt}{\titlerule[1pt]}]
\titlespacing{\chapter}%
   {0mm}% How much of \titlerule line to remove from left
   {8mm}% Before \titlerule
   {0mm}% After \titlerule

and then in one \chapter title I’d like to change a word or two (plus points for possibility to include a \\) the case to lower-case, what should I do?

I’ve found this question, but I could not make it work. Not even the textcase of @DavidCarlisle helped me.

Example headings:

\chapter*{Veľkonočná nedeľa\\ \MakeTextLowercase{alebo}\\ Nedeľa Pánovho zmŕtvychvstania}%

\chapter*{Sobota\\ \MakeTextLowercase{po Piatej pôstnej nedeli}}%
  • Would it be an unnumbered chapter? – Bernard Apr 26 at 15:53
  • In this particular case, yes. Otherwise, it would be nice to have as independent solution as possible (like loading a package). However, any solution is welcome. :) – tukusejssirs Apr 26 at 16:00
  • 1
    You can use \titleformat inside the body of the document,, inside a group. For unnumbered chapters, you have the numberless key. – Bernard Apr 26 at 16:06
  • It is necessary to know what font package you're using. – egreg Apr 26 at 16:29
  • @egreg, I use Libertinus Serif font (package libertinus), as use could see in all my other questions). – tukusejssirs Apr 26 at 16:34
1

You need to reset the “secondary shape” axis to standard; it is defined by the fontaxes package in order to allow for variations in small caps.

\documentclass[a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage[slovak]{babel}

\usepackage{titlesec}

\usepackage{libertinus}

\titleformat{\chapter}[block]
  {\titlerule[1pt]\addvspace{0pt}\Large\scshape\bfseries\centering}
  {\thesection\enspace}
  {0pt}
  {}
  [\vspace{2pt}{\titlerule[1pt]}]
\titlespacing{\chapter}%
   {0mm}% How much of \titlerule line to remove from left
   {8mm}% Before \titlerule
   {0mm}% After \titlerule

\begin{document}

\let\cleardoublepage\relax % just to make both titles go in the same page

\chapter*{Veľkonočná nedeľa\\ \textulc{alebo}\\ Nedeľa Pánovho zmŕtvychvstania}

\chapter*{Sobota\\ \textulc{po Piatej pôstnej nedeli}}

\end{document}

enter image description here

With XeLaTeX you just need \textup:

\documentclass[a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage[slovak]{babel}

\usepackage{fontspec}
\usepackage{titlesec}

\setmainfont{Libertinus Serif}

\titleformat{\chapter}[block]
  {\titlerule[1pt]\addvspace{0pt}\Large\scshape\bfseries\centering}
  {\thesection\enspace}
  {0pt}
  {}
  [\vspace{2pt}{\titlerule[1pt]}]
\titlespacing{\chapter}%
   {0mm}% How much of \titlerule line to remove from left
   {8mm}% Before \titlerule
   {0mm}% After \titlerule

\begin{document}

\let\cleardoublepage\relax

\chapter*{Veľkonočná nedeľa\\ \textup{alebo}\\ Nedeľa Pánovho zmŕtvychvstania}

\chapter*{Sobota\\ \textup{po Piatej pôstnej nedeli}}

\end{document}
  • You say to use fontaxes package, however, you did not included it in the example—have you forgotten it to include? :) – tukusejssirs Apr 26 at 16:50
  • Indeed, from my tests, this code does not work without including fontaxes. And I was misleading in one one comments, when I said that I use libertinus package. I use that font, but I don’t include that as a package, but I use this command instead: \setmainfont{Libertinus Serif}, for which we need to include fontspec package. The textcase package is not necessary. – tukusejssirs Apr 26 at 16:59
  • @tukusejssirs You should be more specific. I assumed pdflatex. – egreg Apr 26 at 16:59
  • I’m sorry, @egreg, however, I assumed you checked the tags. :) – tukusejssirs Apr 26 at 17:00
  • 1
    @tukusejssirs The tag is there, but you said you use the package libertinus. Anyway, with fontspec it's even easier: use \textup. – egreg Apr 26 at 17:04
0

As @Bernard suggested, I could use \titleformat anywhere in the document, not only in the preamble. So I simply created a new command (I named it \chapterOther), where I placed the \titleformat command without \scshape, then called the \chapter, and finally I re-formatted the \chapter with the original \titleformat command. All of this I placed into the preamble:

\newcommand{\chapterOther}[1]{%
    \titleformat{\chapter}[block]%
        {\titlerule[1pt]\addvspace{0pt}\Large\bfseries\centering}%
        {\thesection\enspace}{0pt}{}[\vspace{2pt}{\titlerule[1pt]}]%
    \titlespacing{\chapter}%
        {0mm}% How much of \titlerule line to remove from left
        {8mm}% Before \titlerule
        {0mm}% After \titlerule

    \chapter*{#1}%

    \titleformat{\chapter}[block]
        {\titlerule[1pt]\addvspace{0pt}\Large\scshape\bfseries\centering}
        {\thesection\enspace}{0pt}{}[\vspace{2pt}{\titlerule[1pt]}]
    \titlespacing{\chapter}%
        {0mm}% How much of \titlerule line to remove from left
        {8mm}% Before \titlerule
        {0mm}% After \titlerule
}

And then, when needed, I called it like this:

\chapterOther{\textsc{Veľkonočná nedeľa}\\ alebo\\ \textsc{Nedeľa Pánovho zmŕtvychvstania}}

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.