Skip to content

Instantly share code, notes, and snippets.

@snim2 snim2/tocloft_example
Last active Aug 29, 2015

Embed
What would you like to do?
An example use of tocloft and IEEE format
%
% http://tex.stackexchange.com/questions/197369/how-to-use-tocloft-to-create-a-list-which-appears-in-the-middle-of-the-document
%
% http://tex.stackexchange.com/questions/198326/tocloft-cross-references-a-section-as-a-subsection
%
\documentclass[conference]{IEEEtran}
\usepackage{etoolbox}
\usepackage{lipsum}
\usepackage[titles]{tocloft}
\newcommand{\listexampletitle}{List of Examples}
\newlistof[section]{examples}{exp}{\section{\listexampletitle}}%
\pretocmd{\listofexamples}{\refstepcounter{section}\addtocounter{section}{-1}}{}{}%
\newcommand{\examplelist}[1]{%
\refstepcounter{examples}
\addcontentsline{exp}{examples}
{\protect\numberline{\theexamples}#1}
}
\newcommand{\example}[1]{\examplelist{#1}\textbf{Example \theexamples}: #1}
\cftsetindents{examples}{1.5em}{3.0em}
\cftpagenumbersoff{examples} % Don't print page numbers with examples
\setlength{\cftexamplesnumwidth}{1.5cm} % Add space around example numbers
\begin{document}
\title{Example IEEE with tocleft}
\author{}
\maketitle
\section{Introduction}
\lipsum[1]{}
\example{First example}
\section{A section}
\subsection{A subsection}
\lipsum[1]{}
\example{A second example}
\listofexamples\label{sec:examples}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.