texstudio
texstudio copied to clipboard
Improvement suggestion: Also load label for sub-documents in Side Panel TOC without opening the sub-document
Current behavior
Currently, the labels of the sections of sub-documents in the TOC overview (in the side panel) are only loaded after the sub-document has been opened once in the session. This is noticeable if you want to insert a reference to a label in a sub-document. This is particularly annoying with larger documents.
Improved behavior
It would be nice if the labels were retrieved directly when loading the TOC.
A minimal example
Prerequisite: Restore last session on startup. Tex Project (to skip the first three steps): TeX_files.zip
- Create a new project file -> "New From Template...".
- Select "Book" as the template.
- Generate labels for the two sample chapters via the TOC in the page panel (see Figure 1). After that, the project should correspond to the files from the TeX_files.zip attachment.
- Now it is possible to insert a reference to chapter 1 via the TOC in the side panel (see Figure 2).
- In the next step, close all files except for "main.tex".
- Close TexStudio and open it again (so that only the main.tex file is opened in the next session).
- If you right-click on one of the two chapters in the TOC, only the option create label is displayed (as in Figure 1), but not the option to insert a reference to the existing label.
Figure 1: Creating the label for the first chapter.
Figure 2: Inserting a reference to chapter 1.
Another way to insert labels is main Menu LaTeX/Cross References/ref. As I can see the presented combo box offers all labels.
not sure that I understand correctly. "insert label" adds "\label{sec...} in the line of the section/subsection etc and that can be inserted as reference later. The inserting a reference works when there is a label, so also after reopening the changed and saved file. So, basically you want as second option "create label and insert as reference here" ?
It seems that I can't reproduce with Win10. Root document is open and I see the two subfiles in the list of hidden files:
The context menu shows this:
@sunderme the adding of the "\label{sec...}" is working properly. The subsequent addition of a reference also works. However, when TexStudio is closed and reopened, adding a reference via the context menu is only possible for me if the file with the "\label{sec..." have been opened once in the session.
@octaeder Thank you for looking into this. Maybe it is also an error with my installation. I also tried a reinstallation but the behavior remains the same.
my environment: TeXstudio: 4.7.2 Qt: 6.6.1 OS: Windows 10 TeX distribution: miktex
Update: I have tried the whole thing again on another newly installed PC (same environment). The behavior is the same.
try disabling options/editor/cache documents for faster reopening
That works thanks :)
as a note: this is caused by loading a cached file which does not contain info which label belongs to which section.