[Tex/LaTex] Changing font size for one section heading

fontsizeformattingsectioning

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:

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.

enter image description here

The code:

\documentclass[12pt, a4paper]{article}
\usepackage{titlesec}
\usepackage{lipsum}

\newcommand\stdsubsection{%
  \titleformat{\subsection}
    {\normalfont\large\bfseries}{\thesubsection}{1em}{}
}
\newcommand\largesubsection{%
  \titleformat{\subsection}
    {\normalfont\huge\bfseries\filcenter}{\thesubsection}{1em}{}
}

\begin{document}

\section{Section heading}
\subsection{Normal subsection heading}

\largesubsection
\subsection{Big subsection heading}
\lipsum[66]

\stdsubsection
\subsection{Another normal subsection heading}

\end{document}

With \titleformat*, the code simplifies a little:

\documentclass[12pt, a4paper]{article}
\usepackage{titlesec}
\usepackage{lipsum}

\newcommand\stdsubsection{%
  \titleformat*{\subsection}
    {\normalfont\large\bfseries}
}
\newcommand\largesubsection{%
  \titleformat*{\subsection}{\normalfont\huge\bfseries\filcenter}
}

\begin{document}

\section{Section heading}
\subsection{Normal subsection heading}

\largesubsection
\subsection{Big subsection heading}
\lipsum[66]

\stdsubsection
\subsection{Another normal subsection heading}

\end{document}
Related Question