# Re: [Vim-latex-devel] Aux completion

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}
$$\label{eq:einstein} E = m \, c^2$$
$$a^2 + b^2 = c^2 \label{eq:pythagoras}$$
\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 <perso...@cesdep.org>
>> To: "vim-latex-devel@lists.sourceforge.net"
>>    <vim-latex-devel@lists.sourceforge.net>
>> 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
>> <gerd.wachsm...@mathematik.tu-chemnitz.de> 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)
>>>
>>> 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.
>>>
>>> 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