Skip to content

Instantly share code, notes, and snippets.

@snim2
Last active August 29, 2015 14:05
Show Gist options
  • Save snim2/dcba63a6ddd526ab39bb to your computer and use it in GitHub Desktop.
Save snim2/dcba63a6ddd526ab39bb to your computer and use it in GitHub Desktop.
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