rzukic / zed-latex

33 stars 4 forks source link

Add queries for outlining (part/chapter/section...) #6

Closed lnay closed 4 months ago

lnay commented 4 months ago

Outlining for LaTeX

Add new queries for outlining in LaTeX for:

Outcome:

The context at the cursor is indicated by the breadcrumbs above the buffer, or in the "outline" tab from where you can also navigate the file

Screenshot from 2024-07-19 22-32-21

Subtlety

The curly bracket contents of the corresponding functions may have non-text content but sometimes the declarations include an optional argument in square brackets for the table of contents entry. When present it is safer to use that instead.

% typical part declaration
\part{Part Title} % use "Part Title" for outline name
% alternative with optional argument
\part[table of contents entry]{Part Title \\ with subtitle or maybe even more}
% this time use "table of contents entry" instead since it is provided

Potential Future Improvement

I cannot find any directives that allow to modify the matched text like #gsub! in neovim. But if ever this is possible, it would be good to trim out parts of the outline name which aren't very legible as plain text.

e.g. the ability to search and replace would allow:

\section{Exploring \texorpdfstring{$x^2$}{x squared)}
% use "Exploring x squared" as outline name