Skip to content

Multi-line section titles may lead to empty TOC entries #2364

@xileF1337

Description

@xileF1337

Description

Hi,

I noticed that sometimes vimtex's table of content (TOC) contains empty entries. The issue arises with multi-line section titles like these:

\section{%
    This is a really long section title which is hard-wrapped
    after 80 characters or so to keep the source code readable
}

When opening the TOC using \lt, the corresponding section number will be displayed, but the rest of the line stays blank. The comment symbol % following the opening brace does not seem to make any difference.

Thanks for your help!

Steps to reproduce

I can't attach the tex file, here is the content of, minimal.vim:

\documentclass{article}
\begin{document}

\section{%
    This is a really long section title which is hard-wrapped
    after 80 characters or so to keep the source code readable
}

\end{document}

Steps:

  1. Compile
  2. Open the TOC, by default this is done with \lt.

Expected behavior

Expected behaviour would be to display the full title or the first n non-whitespace characters.

Actual behavior

When opening the TOC using \lt, the corresponding section number will be displayed, but the rest of the line stays blank.

Do you use a latexmkrc file?

no

VimtexInfo

23 System info:                                                                   
 22   OS: Fedora release 33 (Thirty Three)                                         
 21   Vim version: NVIM v0.4.4                                                     
 20   Has clientserver: true                                                       
 19   Servername: /tmp/nvimR51SGy/0                                                
 18                                                                                
 17 VimTeX project: minimal_empty_toc_line                                         
 16   base: minimal_empty_toc_line.tex                                             
 15   root: /homes/foo/Desktop/minimal                                 
 14   tex: /homes/foo/Desktop/minimal/minimal_empty_toc_line.tex       
 13   main parser: current file verified                                           
 12   document class: article                                                      
 11   compiler: latexmk                                                            
 10     engine: -pdf                                                               
  9     options:                                                                   
  8       -verbose                                                                 
  7       -file-line-error                                                         
  6       -synctex=1                                                               
  5       -interaction=nonstopmode                                                 
  4     callback: 1                                                                
  3     continuous: 1                                                              
  2     executable: latexmk                                                        
  1   viewer: General                                                              
24    qf method: LaTeX logfile                                                     
~
~

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions