Skip to content

Instantly share code, notes, and snippets.

@wtsnjp
Created June 9, 2020 01:26
Show Gist options
  • Save wtsnjp/6590638f932f43a79dee41a684a82497 to your computer and use it in GitHub Desktop.
Save wtsnjp/6590638f932f43a79dee41a684a82497 to your computer and use it in GitHub Desktop.
%#!platex
\documentclass[a4paper,dvipdfmx]{jsarticle}
\usepackage{bxjalipsum}
% \enabletoc するまで何も目次に表示させない
\setcounter{tocdepth}{-2}
% 目次記載を始めたい位置で \enabletoc を宣言する
\newcommand{\enabletoc}{%
% tocdepth カウンタの値はお好きなように
\addtocontents{toc}{\setcounter{tocdepth}{2}}}
\begin{document}
\tableofcontents
\section{ほげ}
\jalipsum[1-5]{wagahai}
\enabletoc % <----- この例では,ここで宣言
\section{ふが}
\jalipsum[6-10]{wagahai}
\section{ぴよ}
\jalipsum[11-15]{wagahai}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment