Reputation: 123
The following code demonstrates the default \section
heading along with a custom \tcolorbox
. I would like to alter the \section
default to utilize the custom \tcolorbox
function.
How can I change the default \section
format to the customized \tcolorbox
?
\documentclass[letter,10pt]{article}
\usepackage[utf8]{inputenc}
\RequirePackage[margin=.5in, top=.5in, bottom=1in]{geometry}
\raggedright\raggedbottom
\RequirePackage[most]{tcolorbox}
\newtcolorbox[auto counter]{SectionEnv}{
enhanced,
sharp corners=uphill,
colback=gray!50,
colframe=black,
coltext=black,
arc=3mm,
boxrule=1mm,
boxsep=1mm
}
\begin{document}
\section{Default Section Heading} % <-- default section heading
\begin{SectionEnv}
\textbf{Desired Section Heading}
\end{SectionEnv}
\end{document}
Output of current code:
I reviewed this post on Changing Latex section numbering presentation however was unable to make use of the posted response.
Upvotes: 1
Views: 527
Reputation: 38942
You can use the same approach as in https://latex.org/forum/viewtopic.php?t=33217
\documentclass[letter,10pt]{article}
\usepackage[utf8]{inputenc}
\RequirePackage[margin=.5in, top=.5in, bottom=1in]{geometry}
\raggedright\raggedbottom
\RequirePackage[most]{tcolorbox}
\usepackage{xpatch}
\xpatchcmd{\section}{\normalfont\Large\bfseries}{\sectionbox}{}{\PatchFailed}
\newcommand*{\sectionbox}[1]{%
\begin{tcolorbox}
[
enhanced,
sharp corners=uphill,
colback=gray!50,
colframe=black,
coltext=black,
arc=3mm,
boxrule=1mm,
boxsep=1mm
]
#1
\end{tcolorbox}
} %
\begin{document}
\section{Default Section Heading} % <-- default section heading
\end{document}
Upvotes: 1