texstudio icon indicating copy to clipboard operation
texstudio copied to clipboard

Chapters are not displayed in the structure-tree

Open NTrnka opened this issue 1 year ago • 7 comments

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 TexstudioBugAfter

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. TexstudioBug

How to reproduce

  • Open texstudio
  • see the structure of a automatic restored .tex-file OR
  • open a .tex-file

NTrnka avatar Apr 25 '23 11:04 NTrnka

Confirm. TXS: 4.5.2 Qt 5.15.2 and Qt 6.4.1

idamir avatar Apr 27 '23 13:04 idamir

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:

image

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.

octaeder avatar Apr 27 '23 18:04 octaeder

Screenshot_20230428_104155 Open 30-design.tex Screenshot_20230428_104233 No \chapter, but {sub}section are present. Move \chapter to the next line Screenshot_20230428_104633 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

idamir avatar Apr 28 '23 04:04 idamir

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

  1. Load the main file first after you open TexStudio.
  2. Make sure your subfiles are included in the main file, i.e., there must be this line \subfile{yoursubfilename.tex} in the main file
  3. 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.

kinelite avatar May 05 '23 19:05 kinelite

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:

image

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:

image

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.

octaeder avatar May 06 '23 00:05 octaeder

--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.

octaeder avatar May 06 '23 08:05 octaeder

--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.

sunderme avatar May 06 '23 14:05 sunderme