diff --git a/autoload/vimtex/toc.vim b/autoload/vimtex/toc.vim index 274a268..b753584 100644 --- a/autoload/vimtex/toc.vim +++ b/autoload/vimtex/toc.vim @@ -58,7 +58,7 @@ function! vimtex#toc#init_script() " {{{1 \ } " Define regular expressions to match document parts - let s:re_sec = '\v^\s*\\%(part|chapter|%(sub)*section)\*?\s*\{' + let s:re_sec = '\v^\s*\\%(part|chapter|%(sub)*section)\*?\s*%(\[.{-}\])?\{' let s:re_sec_starred = '\v^\s*\\%(part|chapter|%(sub)*section)\*' let s:re_sec_level = '\v^\s*\\\zs%(part|chapter|%(sub)*section)' let s:re_sec_title = s:re_sec . '\zs.{-}\ze\}?$' diff --git a/test/feature/table-of-contents/frontmatter.tex b/test/feature/table-of-contents/frontmatter.tex index aed32c0..96b4167 100644 --- a/test/feature/table-of-contents/frontmatter.tex +++ b/test/feature/table-of-contents/frontmatter.tex @@ -3,6 +3,6 @@ Preface. \section{Acknowledgements} -\chapter{Other frontmatter chapter} +\chapter[Other]{Other frontmatter chapter} \tableofcontents