Re: [Vim-latex-devel] Aux completion
Brought to you by:
srinathava,
tmaas
From: George <geo...@gm...> - 2017-01-27 21:48:20
|
Hi all, I switched to Gerd's version of vim-latex while I'm writing my thesis. The reason is that I'm using tcolorbox[1] to create coloured boxes for my theorems. Tcolorbox has its own way of labelling theorems, which does not play well with the label completion of vim-latex suite. Here is an example to demonstrate. First I define a theorem environment using tcolorbox, as follows: \newtcbtheorem[number within=section]% {theorem} % \begin.. {Theorem} % Title {} % Style - default {theo} % label prefix; cite as ``theo:yourlabel'' Then, inside my document I can write: \begin{theorem}{The title}{mylabel} This is a theorem. \end{theorem} and I'll get a theorem inside a coloured box. Then I can cite that theorem by writing "\ref{theo:mylabel}". The problem is that if I type "\ref{" and press F9, vim-latex will not recognise the label "theo:mylable", so it won't automplete. Gerd's approach fixes this. That said, I understand that this is a rather special case, but I just thought of throwing it in the discussion. Cheers, George On Fri, Jan 27, 2017, at 20:42, Gerd Wachsmuth wrote: > Thank you for your comments. > > I think I was not precise at one point: You still can use labels for > completion (as long as they are already in the aux file). > > To given an example: > ======================================== > \documentclass{article} > \usepackage{hyperref} > \begin{document} > \begin{equation} > \label{eq:einstein} > E = m \, c^2 > \end{equation} > \begin{equation} > a^2 + b^2 = c^2 > \label{eq:pythagoras} > \end{equation} > \end{document} > ======================================== > > The current version produces the following outline window: > ======================================== > > eq:einstein </tmp/test.tex> > : > > eq:pythagoras </tmp/test.tex> > : a^2 + b^2 = c^2 > ======================================== > You can only use the labels for completion and you see some of the > surrounding text. > > The new, aux-based version produces: > ======================================== > >eq:einstein > : (1) > >eq:pythagoras > : (2) > ======================================== > Here, you can use both, the label and the actual number, with the new > aux completion. However, you do not see some of the text. > > > Moreover, the old mechanism fails to detect if you input some other > files via macros, e.g., > \newcommand{\myinput}[1]{\input{#1}} > and then > \myinput{test}. > Since the labels of the file test.tex still appear in the aux > file, the > aux based completion also find those labels. > > > In my opinion, the only regress is that you have to compile > (once) after > entering a new \label{} and before you will be able to complete a > reference to exactly this label. > > > Best regards, > Gerd > > > On 2017-01-27 10:05, Filip Kadlec wrote: >> Hi, Gerd, >> >> I second Laszlo's point of view; for me, using labels with >> well chosen >> names is clearly the best choice, and I think that the latex- >> suite should >> keep this behavior by default. To me, the <F9>-completion works >> quite well >> and it would maybe need some improvements (it does not work for >> me with >> \includegraphics, and if the vim-window is split when invoking >> <F9> in >> \cite, it oftentimes fails...) but not a complete change of logic. >> >> Your idea to scan the .aux files could be useful for someone, >> though. I >> don't know if it is feasible, but I would suggest an >> implementation via a >> command, something like >> >> let g:Tex_completion_scanfile = tex / aux >> >> whereby everyone would have the choice. >> >> This would does not imply less code nor less maintenance, though. >> >> Best regards, >> Filip >> >> On Thu, 26 Jan 2017, N Laszlo Frazer wrote: >> >>> Date: Thu, 26 Jan 2017 21:33:44 >>> From: N Laszlo Frazer <per...@ce...> >>> To: "vim...@li..." >>> <vim...@li...> >>> Subject: Re: [Vim-latex-devel] Aux completion >>> >>> Please do not remove the current functionality. I think it would >>> be very >>> annoying to rely on the aux file being up-to-date. >>> >>> Well-chosen keys are much easier to remember than numbers, and >>> they do >>> not >>> change when you expand the document. >>> >>> On Fri, 27 Jan 2017 00:52:25 +1100, Gerd Wachsmuth >>> <ger...@ma...> wrote: >>> >>>> Hi, >>>> >>>> in my version of latex-suite >>>> (https://github.com/gerw/vim-latex-suite), >>>> I have changed the mechanism of \ref-completions. The current >>>> version of >>>> latex-suite greps through the tex-file for \labels. My version >>>> greps >>>> through the aux-file. This has the advantage, that one does not >>>> have to >>>> memorize the keys within the \labels for completion, but can >>>> use the >>>> actual labels in the compiled document. >>>> >>>> Hence, you get the following expansions (given that the tex-file >>>> has the >>>> corresponding labels): >>>> >>>> theorem.1.3<F9> => \autoref{thm:bar} >>>> section.2<F9> => \autoref{sec:foo} >>>> (1.9<F9> => \eqref{eq:baz} >>>> (1.9)<F9> => \eqref{eq:baz} >>>> >>>> (You can also reconfigure an option to use \cref (or anything else) >>>> instead of \autoref) >>>> >>>> This is quite convenient, because you can look in the pdf to >>>> get the >>>> appropriate number of the thing you want to refer to and use >>>> this for >>>> the completion. No need for packages like showkeys. >>>> >>>> The only disadvantage is that you get the labels from the aux-file. >>>> Hence, if the aux-file is not up-to-date or you use the numbers >>>> from a >>>> print-out (and the aux-file is more recent), you might get >>>> unexpected >>>> results. >>>> >>>> My question is: Can I replace the current style of the >>>> completion with >>>> this aux-based completion in the official repository? This would >>>> result >>>> in less code (less maintenance) and is therefore desirable. >>>> However, I >>>> can understand if someone would like to stay with the current >>>> behavior. >>>> >>>> The stage is open for discussion, see also >>>> https://github.com/vim-latex/vim-latex/issues/55 >>>> >>>> >>>> Best regards, >>>> Gerd > > > ---------------------------------------------------------------------- > -------- > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > _________________________________________________ > Vim-latex-devel mailing list > Vim...@li... > https://lists.sourceforge.net/lists/listinfo/vim-latex-devel Links: 1. https://www.ctan.org/pkg/tcolorbox?lang=en |