I want to have a single \subsection
printed significantly larger, without otherwise changing the font. This is for a landscape page, to put a subsection title before a full-page diagram, and it needs to be included in the table of contents.
I tried using
\huge{\subsection{Big subsection heading}}
but it doesn't modify the text at all.
Ideally, the solution would use the existing font (rather than hardcoding a font choice which matches the font in this example).
So I tried creating the table-of-contents entry with \nosubsection
(custom), and then using \thesubsection
with the title to create a 'fake' subsection heading.
MWE:
\documentclass[12pt, a4paper]{article}
\usepackage{lipsum}
% don't recall source
\newcommand{\nosubsection}[1]{%
\refstepcounter{subsection}%
\addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection}#1}%
\markright{#1}}
% http://tex.stackexchange.com/questions/73158/how-to-get-the-size-of-the-section-header
\newcommand{\getsubsectionfont}{\setbox0=\vbox{\subsection*{a\xdef\TheSubsectionFont{\the\font}}}}
\AtBeginDocument{\getsubsectionfont}
\begin{document}
\section{Section heading}
\subsection{Normal subsection heading}
% Note the separate \centering
\nosubsection{Big subsection heading}
\centering{\TheSubsectionFont\huge{\thesubsection{} Big subsection heading}}
\label{sec:big}
% Don't know why this is centred too, but it doesn't matter
\lipsum[66]
\end{document}
MWE output:
Best Answer
One option using
titlesec
to define two commands to switch at will between the desired formatting:; use\largesubsection
as many times as desired and at any point, to switch to the larger format;\stdsection
switches back to the regular format.The code:
With
\titleformat*
, the code simplifies a little: