Text Formattingtemporarily get normal subsection after redefining?

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
quickq
Posts: 17
Joined: Wed Oct 13, 2010 8:14 pm

temporarily get normal subsection after redefining?

Post by quickq »

Hi,
I redefined the style of subsection with titlesec package and giving \titleformat and \titlespacing commands. Is there a way I can use original style of subsection in a few particular instances? I tried to read the titlesec documentation but did not see how to do this... thank you.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

temporarily get normal subsection after redefining?

Post by gmedina »

Hi,

you could define two commands; one for the modifications to the subsections format and another for the settings of a standard subsection. The following example illustrates this approach:

Code: Select all

\documentclass{article}
\usepackage{titlesec}

% This command activates the modified format for subsections
\newcommand\MySubsection{%
  \titleformat{\subsection}[runin]
    {\normalfont\Large\itshape}{\thesubsection}{1em}{}
  \titlespacing*{\subsection}
    {0pt}{10pt}{0.5em}
}
% This command activates the standard format for subsections
\newcommand\StdSubsection{%
  \titleformat{\subsection}
    {\normalfont\large\bfseries}{\thesubsection}{1em}{}
  \titlespacing*{\subsection}
    {0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
}

\begin{document}

\section{Test section}

\MySubsection
\subsection{A modified subsection}
text text

\StdSubsection
\subsection{A standard subsection}
text text

\MySubsection
\subsection{Another modified subsection}
text text

\StdSubsection
\subsection{Another standard subsection}
text text

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
quickq
Posts: 17
Joined: Wed Oct 13, 2010 8:14 pm

Re: temporarily get normal subsection after redefining?

Post by quickq »

Hi,

Thank you. This might be obvious but - how did you know what the standard options were?
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

temporarily get normal subsection after redefining?

Post by gmedina »

You can find them in the file article.cls or in the documentation of the titlesec package (Section "Standard Classes").
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply