LaTeXTools icon indicating copy to clipboard operation
LaTeXTools copied to clipboard

Customize \ref completion

Open JakobScholbach opened this issue 5 years ago • 2 comments
trafficstars

I love a feature of LatexTools: if I type \ref{, it automatically scans for all occurrences of \label{…} and offers these for some auto-completion.

How do I customize this? I want to achieve the same behavior with \thref{ and \thlabel{…} instead.

Thanks!

JakobScholbach avatar Feb 21 '20 11:02 JakobScholbach

The behavior of ref and label is hard coded and not configurable. You may however adapt the source code. Select View > Browse Packages... then open the LaTeXTools folder and the file latex_ref_completions.py.

Then add "th" to the array in this line (i.e. "title", "headname", "tocname", "th") to open the completion for \thref.

Then adapt this line to

for command in doc.filter_commands(['label', 'thlabel']):

and this line to

view.find_all(r'\\(?:th)?label\{([^\{\}]+)\}', 0, '\\1', completions)

to also scan the \thlabel commands

r-stein avatar Feb 21 '20 14:02 r-stein

Thank you, r-stein, this works!

JakobScholbach avatar Feb 21 '20 15:02 JakobScholbach