texstudio
texstudio copied to clipboard
Chapters are not displayed in the structure-tree
When opening a Document with chapters, sections etc. in the structure tree on the left side, the chapters are not shown. They reappear, if the \chapter{chaptername}-command is edited.
Environment
- TeXstudio 4.5.2 (git 4.5.2)
- Qt-Version 6.5.0, kompiliert mit Qt 6.5.0 R
- OS: Windows 10
- TeX distribution: texlive
Expected behavior
Open a .tex-File and see all chapters with sections and so on in the structure-tree on the left side
Actual behavior
If TexStudio is opened and reopens the .tex OR if the .tex is opened via the Structure-tree OR if the .tex is opened via TexStudio, the chapters do not appear in the structure-tree. If the corresponding \chapter{chaptername}-command is edited (for example if a space is inserted and deleted anywhere in the command or the name inside the command), the entry reappears.
How to reproduce
- Open texstudio
- see the structure of a automatic restored .tex-file OR
- open a .tex-file
Confirm. TXS: 4.5.2 Qt 5.15.2 and Qt 6.4.1
I can't confirm such a behavior. I tested on win10 with current portable (4.5.2 Qt6.5.0) and with msys2 build 4.5.2-12-gd1dd9ef9b Qt6.4.2). I tested this option:
When I have activated only current documents and reactivate all docs then at first only the names of the hidden files reappear. Clicking on those names brings back the structure of the file.
Open 30-design.tex
No \chapter, but {sub}section are present.
Move \chapter to the next line
All sections disappear until they are edited.
Some video. https://user-images.githubusercontent.com/4737692/235053288-00931700-eb6a-49e7-a924-37501a427ad2.mp4
Exactly the same as described in #3091
This problem #3086 has occurred to me for almost a year now. It always occurs when .tex subfiles are loaded but the .tex main file has not been loaded.
The only solution I found is
- Load the main file first after you open TexStudio.
- Make sure your subfiles are included in the main file, i.e., there must be this line \subfile{yoursubfilename.tex} in the main file
- Load the your subfiles next, and enjoy the fixed structure-tree.
However, this is just a temporary solution and it's very inconvenient. If you are working with many subfiles at once, then having all subfiles included in the main file will result it a major increase in compiling time because ALL files will have to be compiled. The only fix is you have to exclude the other subfiles you are not working with at the moment from the main file. This is very tedious because you have to do that each time you are working with different subfile.
I hope the structure-tree is fixed and recovered again without having to load the main file.
Please check if you have unreferenced labels. Following example can reproduce the behavior in 4.5.1 and 4.5.2 on Win10:
\documentclass{article}
\begin{document}
%
%
\section{Nothing}
\label{a}
\end{document}
Insert this in an editor and the structure looks like this:
Now set cursor at the beginning of the line with the first percent sign. Press enter, then undo with Ctrl+Z, and be aware of the removed section in the structure:
It won't happen if you start with the cursor in the line of the second percent sign, or if you have only one line with a percent sign, or if you remove the label.
It took me a lot of time to find this example and I hope it helps to find the reason why this happens.
--Edited-- it seems that it is rather a problem of deleting lines and labels (referenced or not):
\documentclass{article}
\begin{document}
a
b
c
d
e
\section{Nothing}
\label{a}
\ref{a}
\end{document}
set cursor in any of the lines a, b, ..., d and press Ctrl+K, or with cursor at the end of one of those lines and press enter, then backspace. This doen't happen with line e.
--Edited-- it seems that it is rather a problem of deleting lines and labels (referenced or not):
\documentclass{article} \begin{document} a b c d e \section{Nothing} \label{a} \ref{a} \end{document}
set cursor in any of the lines a, b, ..., d and press Ctrl+K, or with cursor at the end of one of those lines and press enter, then backspace. This doen't happen with line e.
This is probably an example for #3091. Anyway fixed, though it has nothing to do with chapters not showing up.