I'm fairly new to LaTeX, and I have no idea how to fix this. Basically I make a subsection using \section, and then create subsections using \subsectiond. Now I need to create bullets within the subsection, but I can't find syntax that works. Can anybody help me out?
[Tex/LaTex] Creating bullets within a subsection
formatting
Related Solutions
If you redefine \thesubsection
it would carry over to the TOC:
\renewcommand*{\thesubsection}{\thesection~\S~\arabic{subsection}}
Or start by adding it to \thesection
:
\renewcommand*{\thesection}{\arabic{section}~\S}
\renewcommand*{\thesubsection}{\thesection~\arabic{subsection}}
Note, I used ~
instead of \
because a line break between number and ยง is not very desirable.
Here's one way to do it:
\documentclass[12pt]{article}
\usepackage{blindtext}
\usepackage{etoolbox}
\usepackage{titlesec}
\usepackage{titletoc}
\titleformat{\section} % command
[hang] % shape
{\normalsize\bfseries} % format
{\thesubsection} % label
{1em} % Spacing between label and title
{\MakeUppercase} % before code
\titlespacing{\section}% Set the spacing around the title
{0pt} % Left
{0pt} % Above
{0pt} % Below
\newcommand\RegToCEntries{
\titlecontents{section}[2em]
{\vspace{12pt}}
{\normalfont\normalsize\contentslabel[\thecontentslabel.0]{2em}\uppercase}
{\hspace*{-2em}\uppercase}
{\titlerule*[.75em]{.}\contentspage}
}
\newcommand\AppToCEntries{
\titlecontents{section}[0em]
{\vspace{12pt}}
{\normalfont\normalsize\contentspush{\MakeUppercase{\appendixname}}%
\contentslabel{-1em}\hspace{2em}\makebox[1em][l]{--}%
}
{\hspace*{-2em}}
{\titlerule*[.75em]{.}\contentspage}
}
\AtBeginDocument{\RegToCEntries}
\pretocmd{\appendix}{\AppToCEntries}{}{}
\patchcmd{\tableofcontents}
{\contentsname}
{\hfill\MakeUppercase{\contentsname}\hfill\null}
{}
{}
\titleformat{\subsection} % command
[hang] % shape
{\bfseries\normalsize} % format
{\thesubsection} % label
{1em} % Spacing between label and title
{} % before code
\titlespacing{\subsection}% Set the spacing around the title
{0pt} % Left
{0pt} % Above
{0pt} % Below
\titleformat{\subsubsection} % command
[runin] % shape
{\bfseries\normalsize} % format
{\thesubsubsection} % label
{1em} % Spacing between label and title
{} % before code
[.] % after code
\begin{document}
\tableofcontents
\clearpage% just for the example
\blinddocument
\appendix
\section{A test appendix}
\section{Another test appendix}
\end{document}
The result:
Explanation
Center the ToC title.
I used the
etoolbox
package to patch\tableofcontents
:\patchcmd{\tableofcontents} {\contentsname} {\hfill\MakeUppercase{\contentsname}\hfill\null} {} {}
Formatting for section entries.
I defined two commands
\RegToCEntries
and\AppToCEntries
:\newcommand\RegToCEntries{ \titlecontents{section}[2em] {\vspace{12pt}} {\normalfont\normalsize\contentslabel[\thecontentslabel.0]{2em}\uppercase} {\hspace*{-2em}\uppercase} {\titlerule*[.75em]{.}\contentspage} } \newcommand\AppToCEntries{ \titlecontents{section}[0em] {\vspace{12pt}} {\normalfont\normalsize\contentspush{\MakeUppercase{\appendixname}}% \contentslabel{-1em}\hspace{2em}\makebox[1em][l]{--}% } {\hspace*{-2em}} {\titlerule*[.75em]{.}\contentspage} }
The first one gives the desired formatting for regular sections and the seccond one, for sections in appendix; I added Appendix using
\contentspush
. The first command is used\AtBeginDocument
:\AtBeginDocument{\RegToCEntries}
and the second one is applied automatically after invoking
\appendix
:\pretocmd{\appendix}{\AppToCEntries}{}{}
Suggestion
Your code sets
\titlespacing{\section}% Set the spacing around the title
{0pt} % Left
{0pt} % Above
{0pt}
which suppresses spacing around section titles; I'd suggest you to use positive values in the last two arguments so section titles will have better vertical spacing with respect to the surrounding text.
Best Answer
It should work out if you just use the following syntax at the respective place in your document:
That way, it should be working, now matter whether you are writing within a section or a subsection or even a subsubsection. :)