CTAN Comprehensive TeX Archive Network

Direc­tory macros/latex/contrib/etoc

Source:  etoc.dtx (v1.09-2019/03/09)
Author:  Jean-Francois Burnol
Author:  Christine Roemer et al. (German tranlation)
Info:    Completely customisable TOCs
License: LPPL 1.3c
Copyright (C) 2012-2019 Jean-Francois Burnol.
Copyright (C) 2014-2019 Christine Roemer and collaborators for
the translation into German of the documentation.
<jfbu at free dot fr>    <Christine_Roemer at t-online dot de>


The etoc pack­age gives to the user com­plete con­trol on how the en­tries of the ta­ble of con­tents should be con­sti­tuted from the name, num­ber, and page num­ber of each sec­tion­ing unit. This goes via the def­i­ni­tion of line styles for each sec­tion­ing level used in the doc­u­ment. The pack­age pro­vides its own cus­tom line styles. Sim­pler ones are given as ex­am­ples in the doc­u­men­ta­tion. The sim­plest us­age will be to take ad­van­tage of the lay­out fa­cil­i­ties of pack­ages deal­ing with list en­vi­ron­ments.

Re­gard­ing the global toc dis­play, etoc pro­vides pre-de­fined styles based on a multi-col­umn for­mat, with, op­tion­ally, a ruled ti­tle or framed con­tents.

The \tableofcontents com­mand may be used ar­bi­trar­ily many times and it has a vari­ant \localtableofcontents which prints ta­bles of con­tents 'lo­cal' to the cur­rent sur­round­ing doc­u­ment unit. An ex­ten­sion of the \label/\ref syn­tax al­lows to re­pro­duce (with an­other lay­out) a lo­cal ta­ble of con­tents de­fined some­where else in the doc­u­ment.

Via depth tags, one gets an even finer con­trol for each ta­ble of con­tents of which sec­tion­ing units it should, or not, dis­play.

The for­mat­ting in­her­ited (and pos­si­bly cus­tomized by other pack­ages) from the doc­u­ment class will be used when in com­pat­i­bil­ity mode.

The as­sign­ment of lev­els to the sec­tion­ing units can be changed at any time, and etoc can thus be used in a quite gen­eral man­ner to cre­ate cus­tom ''lists of'', ad­di­tion­ally to the ta­bles of con­tents re­lated to the doc­u­ment sec­tion­ing units. No aux­il­iary file is used ad­di­tion­ally to the stan­dard .toc file.


The sim­plest is to down­load


and then run unzip etoc.tds.zip -d <DEST> where <DEST> is a TDS-com­pli­ant reper­tory.

Else, to ex­tract the pack­age (.sty) and driver (.tex) files from etoc.dtx:

  • if etoc.ins is present: etex etoc.ins
  • with­out etoc.ins: etex etoc.dtx

It is also pos­si­ble to run la­tex or pdfla­tex di­rectly on etoc.dtx.

To pro­duce etoc.pdf one can run pdfla­tex (thrice) di­rectly on etoc.dtx or on the file etoc.tex which was ex­tracted from pre­vi­ous step.

Op­tions can be set in etoc.tex:

  • scr­doc class op­tions (pa­per size, font size, ...)
  • with or with­out source code,
  • with dvipdfmx or with la­tex+dvips or pdfla­tex.

Since re­lease 1.08h pdfla­tex is the de­fault in etoc.tex (prior it was la­tex+dvipdfmx as it pro­duces smaller PDFs) in or­der to al­low in­clu­sion via the use of pack­age attachfile of about 25 code sam­ples as file at­tach­ment an­no­ta­tions.


etoc.sty    -> TDS:tex/latex/etoc/etoc.sty
etoc.dtx    -> TDS:source/latex/etoc/etoc.dtx
etoc.pdf    -> TDS:doc/latex/etoc/etoc.pdf
etoc-DE.pdf -> TDS:doc/latex/etoc/etoc-DE.pdf
README.md   -> TDS:doc/latex/etoc/README.md

The other files may be dis­carded.


This Work may be dis­tributed and/or mod­i­fied un­der the con­di­tions of the Project Public Li­cense, in its ver­sion 1.3c. This ver­sion of this li­cense is in


and the lat­est ver­sion of this li­cense is in


and ver­sion 1.3 or later is part of all dis­tri­bu­tions of ver­sion 2005/12/01 or later.

The Authors of this Work are:

  • Jean-Fran­cois Burnol <jfbu at free dot fr> for the source code and English doc­u­men­ta­tion, and
  • Chris­tine Roe­mer <Christine_Roemer at t-online dot de> and col­lab­o­ra­tors for the trans­la­tion into Ger­man of the doc­u­men­ta­tion.

This Work con­sists of the main source file etoc.dtx and the de­rived files etoc.sty, etoc.ins, etoc.tex, etoc-DE.tex, etoc.pdf, etoc-DE.pdf, etoc.dvi, etoc-DE.dvi.


v1.09 [2019/03/09]

New fea­tures: \etoclocaltop, \localtableofcontentswithrelativedepth. Thanks to Tony Roberts for fea­ture re­quest.

Note to hack­ers: in­ter­nal con­trol se­quence \Etoc@localtop is gone.

etoc now re­quires (\numexpr, \unless).

v1.08p [2018/07/04]

Fixed bug sur­fac­ing in case of linktoc=page op­tion of hy­per­ref. Thanks to De­nis Bi­touzé for re­port (cf. https://github.com/ho-tex/hy­per­ref/is­sues/65, https://github.com/dbitouze/yathe­sis/is­sues/61).

v1.08o [2018/06/15]

Fixed bug show­ing up if an un­num­bered TOC en­try starts with a brace, and doc­u­ment uses hy­per­ref. Caused by a typo in a macro name at pre­vi­ous re­lease.

v1.08n [2018/02/23]

Re­fac­tor­ing of core macros de­tect­ing \numberline and its vari­ants.

v1.08m [2018/02/07]

Fix to 1.08k's in­tro­duced in­com­pat­i­bil­ity with KOMA-script and tocba­sic's \nonumberline.

v1.08l [2017/10/23]

Workaround an is­sue with Emacs/AUCTeX wrongly re­port­ing about ac­tu­ally non-ex­is­tent er­rors, which was trig­gered by some strings writ­ten (in­di­rectly) to log file by etoc un­der some cir­cum­stances.

v1.08k [2017/09/28]

Adds \etocsetlocaltop.toc. See cor­re­spond­ing man­ual sec­tion for de­tails.

Adds \etocsavedparttocline, \etocsavedchaptertocline, \etocsavedsectiontocline, ... They can be used in the con­text of the tech­nique ex­plained in sec­tion "Another com­pat­i­bil­ity mode".

Formerly, etoc re­de­fined for the du­ra­tion of the TOC the mem­oir macro \chapternumberline and its likes to have same mean­ing as \numberline (of course, not when ex­e­cuted in com­pat­i­bil­ity mode), for the sake of ex­trac­tion of \etocnumber.

New method de­tects pres­ence of any \<foo>numberline macro with­out any change to orig­i­nals; they can thus be used as is when ap­ply­ing the ap­proach of "Another com­pat­i­bil­ity mode" sec­tion from man­ual.

v1.08j [2017/09/21]

Since 1.08a-2015/03/13 \etocname, \etocnumber, \etocpage con­tain, if hy­per­ref is present and con­fig­ured for us­ing hy­per­links in the TOC, the link des­ti­na­tion in al­ready ex­panded form. This means one can use them even if the style closes a group (for ex­am­ple from a & in a tab­u­lar), if \etocglobaldefs was is­sued; also one can save their mean­ing for de­layed us­age (with for ex­am­ple \LetLtxMacro as they are ro­bust).

But for some legacy rea­son \etoclink, con­trar­ily to \etocthelink, was han­dled dif­fer­ently. Now, \etoclink also con­tains the link des­ti­na­tion in al­ready ex­panded form, and can thus be used even if the line style is­sues a &, as long as \etocglobaldefs is is­sued.

Also, bugs dat­ing back to the early days of the pack­age, but sur­fac­ing only un­der rel­a­tively rare con­di­tions such as us­age of hy­per­ref with its op­tion "link­toc=page" got fixed.

v1.08i [2016/09/29]

This fixes an is­sue dat­ing back to 1.08e-2015/04/17: un­der \etocchecksemptiness regime, some cir­cum­stances (such as adding to an al­ready com­piled doc­u­ment a \localtableofcontents be­fore the main \tableofcontents) cre­ated an "Undefined control sequence \Etoc@localtop" er­ror. Thanks to De­nis Bi­touzé for re­port­ing the prob­lem.

On this oc­ca­sion, \etocdoesnotcheckemptiness has been added to un­set the flag.

A rather more ex­otic is­sue was fixed: the empti­ness check for lo­cal tocs could get con­fused if the tocdepth counter was vary­ing in some spe­cific ways from in­side the toc file.

After adding to a doc­u­ment a \localtableofcontents, two passes are needed for etoc to get a chance to print the cor­rect lo­cal con­tents. Formerly, etoc is­sued a Warn­ing on the first pass; it now also in­duces into an­nounc­ing "There were un­de­fined ref­er­ences", as this is nearer to the end of the log file and con­sole out­put.

v1.08h [2016/09/25]

New func­tion­ing of \etocsetnexttocdepth: the tocdepth counter is mod­i­fied only at the time of the ta­ble of con­tents, not be­fore. This fixes an is­sue which arose when \etocsetnexttocdepth was used mul­ti­ple times with no in­ter­ven­ing ta­ble of con­tents. Thanks to De­nis Bi­touzé for re­port­ing the prob­lem.

The PDF doc­u­men­ta­tion in­cludes about 25 code snip­pets also as file at­tach­ment an­no­ta­tions, ad­di­tion­ally to their ver­ba­tim type­set­ting. The or­der­ing of the doc­u­men­ta­tion con­tents has been slightly re-or­ga­nized.

A pre­vi­ous doc­u­men­ta­tion-only up­date on 2016/09/09 added a new sec­tion with the (ap­prox­i­mate) trans­la­tion into etoc lin­gua of the book class toc style, for easy cus­tomiz­abil­ity.

The lat­est trans­la­tion into Ger­man of the ad­di­tions made to the doc­u­men­ta­tion dates back to v1.08d [2015/04/09].

Thanks to Chris­tine Römer!

Down­load the con­tents of this pack­age in one zip archive (1.2M).

etoc – Com­pletely cus­tomis­able TOCs

The pack­age gives the user com­plete con­trol of how the en­tries of the ta­ble of con­tents should be con­sti­tuted from the name, num­ber, and page num­ber of each sec­tion­ing unit. The lay­out is con­trolled by the def­i­ni­tion of ‘line styles’ for each sec­tion­ing level used in the doc­u­ment.

The pack­age pro­vides its own cus­tom line styles (which may be used as ex­am­ples), and con­tin­ues to sup­port the stan­dard for­mat­ting in­her­ited from the doc­u­ment classes, but the pack­age can also al­low the user to del­e­gate the de­tails to pack­ages deal­ing with list mak­ing en­vi­ron­ments (such as en­u­mitem). The pack­age’s de­fault global style type­sets ta­bles of con­tents in a multi-col­umn for­mat, with ei­ther a stan­dard head­ing, or a ruled ti­tle (op­tion­ally with a frame around the ta­ble).

The \table­of­con­tents com­mand may be used ar­bi­trar­ily many times in the same doc­u­ment, while \lo­caltable­of­con­tents pro­vides a ‘lo­cal’ ta­ble of con­tents.

Ver­sion1.09 2019-03-09
Li­censesThe Project Public Li­cense 1.3c
Copy­right2012–2019 Jean-François Burnol
Main­tainerJean-François Burnol
TDS archiveetoc.tds.zip
Con­tained inTeX Live as etoc
MiKTeX as etoc
TOC etc
See alsotocbasic
Guest Book Sitemap Contact Contact Author