Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F9 \cite and \ref completion does not work anymore #135

Open
yipeah opened this issue Jul 2, 2018 · 24 comments
Open

F9 \cite and \ref completion does not work anymore #135

yipeah opened this issue Jul 2, 2018 · 24 comments

Comments

@yipeah
Copy link

yipeah commented Jul 2, 2018

Hello,

I have been using latex-suite for several years and am currently using gvim 7.4.1689 and latex suite 1.9.0 on Ubuntu 16.04.

Typically, I was able to use F9 for \cite and \ref completion without a problem. I do not know why but for some time now, pressing F9 after for example \cite{ only produces empty outline buffers with no visible error message, even with files that previously worked.

When pressing F9 after having typed \ref{, I very briefly see an error message that disappears very fast, related to python3.5 and outline.py.

I've disabled the use of python by setting g:Tex_UsePython=0 in tex.vim but this does not restore the initial behavior.

Also, I installed latex-suite 1.10 to see if it makes a difference, but the observed behavior remains the same.

I have noticed that the F9 completion has been causing some issues for users on and off. None of the answers that I read on the internet were able to help me solve my problem.

What kind of additional information would you need from me to diagnose and possibly fix the problem on my installation?

Thanks a lot in advance!

Kim

@gerw
Copy link
Contributor

gerw commented Jul 2, 2018

Maybe this is related to python. Can you tell me what

:echo Tex_HasPython
:echo Tex_UsePython()
:echo Tex_GetVarValue('Tex_UsePython')
:echo Tex_GetVarValue('Tex_UseCiteCompletionVer2')

yield? Afterwards, it would be nice if you could enable debugging

let g:Tex_Debug = 1
let g:Tex_DebugLog = "vim-latex-suite.log"

then press F9 at an appropriate position. What does the log file contain?

@yipeah
Copy link
Author

yipeah commented Jul 2, 2018

Hi Gerd,

Please find below the answers to your question. Thanks for your help!

:echo Tex_HasPython
3
:echo Tex_UsePython()
1
:echo Tex_GetVarValue('Tex_UsePython')
1
:echo Tex_GetVarValue('Tex_UseCiteCompletionVer2')
1

A minimal example:

\documentclass[pdftex,a4paper,12pt]{article}
\usepackage[pdftex]{graphicx}
\usepackage{natbib}
\usepackage{hyperref}
\begin{document}
\bibliographystyle{kluwer}
\section{Start of minimal example}\label{FirstSection}
\cite{ART_MILFERSTEDT2013}. Section~\ref{FirstSection}
\bibliography{/home/kim/Documents/mine/article_information/databases/110324.bib}%
%GATHER{/home/kim/Documents/mine/article_information/databases/110324.bib}
\end{document}

The logfile output after typing F9 after \cite{ :

view : Tex_Complete: s:type = cite, typeoption =
view : :Tex_Complete: using s:prefix =
view : :Tex_FindBibFiles:
view : Tex_FindBibFiles: found bibliography command in 180702_minimal_test.tex
view : :Tex_FindBibFiles: trying to search through [/home/kim/Documents/mine/article_information/databases/110324.bib]
view : :Tex_FindBibFiles: returning [/home/kim/Documents/mine/article_information/databases/110324.bib
]

Strangely enough, after typing \ref{ , I was presented a menu from which I could chose a label. So this seemed to have worked this time.

Best wishes,

Kim

@yipeah
Copy link
Author

yipeah commented Jul 9, 2018

Hello,

The \ref{ completion works in my minimal example, however, the \cite completion does not work at all.

In my more complex document, also \ref{ doesn't work even though it used to work just fine before.

If noticed today that when typing \cite{, the syntax is not highlighted in red as for example for \ref{. I wonder if this is somehow related to cite completing not working as it is somehow not recognized (any more)?

Kim

@gerw
Copy link
Contributor

gerw commented Jul 10, 2018

It seems that your are using a very old version of latex-suite. Please update and try again. (And please post the new log file).

@gerw
Copy link
Contributor

gerw commented Jul 10, 2018

It would also be helpful if you post your bib-file.

@jcwomack
Copy link

jcwomack commented Jun 4, 2019

I have noticed similar behaviour using (G)Vim 8.0 with latex-suite 1.9.0 on Ubuntu 18.04 LTS, with latex-suite installed from Ubuntu's package repositories. I have no \cite completion issues and \ref completion works fine, unless I have a \label within a figure environment, in which case a Python error message briefly appears, then vanishes leaving an empty __OUTLINE__ window. Removing the \label from the figure environment restores the usual behaviour.

Is this issue still open? I'm happy to follow the steps above (e.g. post values of the variables and a debug log), but want to check whether this has already been resolved before proceeding.

If the bug is resolved in a later version of latex-suite, then I can file a bug report against the Ubuntu package (https://packages.ubuntu.com/bionic/vim-latexsuite).

@gerw
Copy link
Contributor

gerw commented Jun 4, 2019

Can you post a minimal tex-file for which the completion is broken?

@jcwomack
Copy link

jcwomack commented Jun 5, 2019

Sure. Here is a minimal example:

\documentclass{article}

\begin{document}
\section{First}
\label{sec:first}

\subsection{Second}
\label{subsec:second}

\ref{sec:first}
\ref{}
  \begin{figure}
    \label{fig:figure}
  \end{figure}
\end{document}

I have also managed to capture most of the error message (it turns out that if your window is smaller than the error message, then the error message is paged, so does not immediately disappear).

If I switch to insert mode and press F9 within the curly brackets for the \ref command in the above example, then the error below occurs and an empty __OUTLINE__ window is shown.

"__OUTLINE__" [New File]
line   23:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jcw1u14/.vim/ftplugin/latex-suite/outline.py", line 191, in main
    return getSectionLabels(lineinfo, label_prefix=label_prefix)
  File "/home/jcw1u14/.vim/ftplugin/latex-suite/outline.py", line 162, in getSectionLabels
    sections[0], sectypes[1:], section_prefix, label_prefix)
  File "/home/jcw1u14/.vim/ftplugin/latex-suite/outline.py", line 170, in getSectionLabels
    section_prefix + ('%d.' % sec_num), label_prefix)
  File "/home/jcw1u14/.vim/ftplugin/latex-suite/outline.py", line 170, in getSectionLabels
    section_prefix + ('%d.' % sec_num), label_prefix)
  File "/home/jcw1u14/.vim/ftplugin/latex-suite/outline.py", line 162, in getSectionLabels
    sections[0], sectypes[1:], section_prefix, label_prefix)
  File "/home/jcw1u14/.vim/ftplugin/latex-suite/outline.py", line 150, in getSectionLabels
    return getSectionLabels_Root(lineinfo, section_prefix, label_prefix)
  File "/home/jcw1u14/.vim/ftplugin/latex-suite/outline.py", line 100, in getSectionLabels_Root
    cm = re.search(r'\caption(\[.*?\]\s*)?{(.*?)}', prev_txt)
  File "/usr/lib/python3.6/re.py", line 182, in search
    return _compile(pattern, flags).search(string)
  File "/usr/lib/python3.6/re.py", line 301, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.6/sre_compile.py", line 562, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.6/sre_parse.py", line 855, in parse
    p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
  File "/usr/lib/python3.6/sre_parse.py", line 416, in _parse_sub
    not nested and not items))
  File "/usr/lib/python3.6/sre_parse.py", line 502, in _parse
    code = _escape(source, this, state)
  File "/usr/lib/python3.6/sre_parse.py", line 401, in _escape
    raise source.error("bad escape %s" % escape, len(escape))
sre_constants.error: bad escape \c at position 0
line   24:
Traceback (most recent call last):
  File "<string>", line 1, in <module>

only the last line is missing from this error message.

If I comment out the \label in the figure environment, then press F9 in the same place, then the error does not occur and the __OUTLINE__ window contains the expected entries for the labelled sections.

@gerw
Copy link
Contributor

gerw commented Jun 5, 2019

This bug was fixed two years ago: 7d60db0.

@jcwomack
Copy link

jcwomack commented Jun 6, 2019

Thanks for the quick response. Okay, for my own purposes, I will switch to a manual installation of the 1.10.0 release.

I can also file a bug report for the Ubuntu package (1.9.0) and request that the package be updated to incorporate this fix. It looks like the package is at 1.9.0 for post 18.04 LTS versions of Ubuntu.

@jcwomack
Copy link

jcwomack commented Jun 7, 2019

I have created a bug report for the Ubuntu package: https://bugs.launchpad.net/ubuntu/+source/vim-latexsuite/+bug/1831989

@jcwomack
Copy link

jcwomack commented Jun 7, 2019

I can confirm that this issue is not present when the latest release of Vim LaTeX suite (1.10.0, from github) is manually installed as a package in Vim 8.0 on Ubuntu 18.04 LTS. Thanks for your help @gerw .

@gerw
Copy link
Contributor

gerw commented Jun 7, 2019

You are welcome!

@mowgli
Copy link

mowgli commented May 1, 2021

I have the same issue as the OP. \ref{… is working, \cite{… is not.

I use the most recent version from git (master).

\addbibresource{../literatur.bib}
…
\begin{document}
\autocite{<F9>

With a bibtex file like:

% Encoding: ISO-8859-1

@String{PHZH = {Pädagogische Hochschule Zürich}}

@Online{lp21de1,
  url            = {https://zh.lehrplan.ch/lehrplan_printout.php?k=1&z=1&ekalias=0&fb_id=1&f_id=11},
  subtitle       = {Deutsch},
  titleaddon     = {Kompetenzaufbau 1. Zyklus},
  urldate        = {2020-02-25},
  crossref       = {lp21},
  groups         = {Deutsch},
  keywords       = {qualityAssured},
  qualityassured = {qualityAssured},
}

@Online{lp21ma1,
  url            = {https://zh.lehrplan.ch/lehrplan_printout.php?k=1&z=1&ekalias=0&fb_id=5},
  subtitle       = {Mathematik},
  titleaddon     = {Kompetenzaufbau 1. Zyklus},
  urldate        = {2020-02-25},
  crossref       = {lp21},
  groups         = {Mathe},
  keywords       = {qualityAssured},
  qualityassured = {qualityAssured},
}

It does not help to all capitalize the keys.

@mowgli
Copy link

mowgli commented May 1, 2021

Ah yes, the debug log:


view : Tex_Complete: s:type = autocite, typeoption = 
view : :Tex_Complete: using s:prefix = 
view : :Tex_FindBibFiles: 
proj : texproject.vim: catching LatexSuiteFileType event
env : envmacros.vim: Catching LatexSuiteFileType event
comp : compiler.vim: Catching LatexSuiteFileType event
fold : folding.vim: catching LatexSuiteFileType
brak : brackets.vim: Catching LatexSuiteFileType event
view : texviewer.vim: Catching LatexSuiteFileType event
main : main.vim: Catching LatexSuiteFileType event
pack : packages.vim: Catching LatexSuiteFileType event
pack : +Tex_pack_updateall
view : Tex_FindBibFiles: found bibliography command in lnw1.tex
view : :Tex_FindBibFiles: bib command from line 6 to line 6
view : :Tex_FindBibFiles: concatenated bib command: "../literatur.bib}"
view : :Tex_FindBibFiles: trying to search through [../literatur.bib]
view : :Tex_FindBibFiles: in this file: [/home/klaus/tex/Lehrer/literatur.bib
]
view : :Tex_FindBibFiles: scanning recursively in [/home/klaus/tex/Lehrer/acronyms.inc]
view : :Tex_FindBibFiles: 
view : :Tex_FindBibFiles: in this file: []
view : :Tex_FindBibFiles: with included files: []
view : :Tex_FindBibFiles: with included files: [/home/klaus/tex/Lehrer/literatur.bib
]

Edit: Could it be that the \n at the end of the file name is causing the troubles?

@mowgli
Copy link

mowgli commented May 1, 2021

And here is a minimal LaTeX file:

\documentclass{scrartcl}
\begin{filecontents}[overwrite]{test.bib}
@Book{spiegel2018,
  author         = {Hartmut Spiegel and Christoph Selter},
  date           = {2018},
  title          = {Kinder \& Mathematik},
  edition        = {10},
  foreword       = {Ranga Yogeshwar},
  isbn           = {3-7800-5238-5},
  language       = {german},
  location       = {Seelze},
  pagetotal      = {112},
  publisher      = {Kallmeyer},
  subtitle       = {Was Erwachsene wissen sollten},
  ean            = {978-3-7800-5238-4},
  groups         = {Mathe},
  keywords       = {qualityAssured, read},
  qualityassured = {qualityAssured},
  readstatus     = {read},
}
\end{filecontents}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{biblatex-chicago}
\addbibresource{test.bib}
\begin{document}

\end{document}

@gerw
Copy link
Contributor

gerw commented May 1, 2021

Your MWE cannot work since the filecontents writes to a different place than the \addbibresource.

LaTeX-Suite correctly identifies your bib file. The \n is intended. What happens after you are pressing F9? Does the OUTLINE window open?

@mowgli
Copy link

mowgli commented May 2, 2021 via email

@mowgli
Copy link

mowgli commented May 2, 2021

I have to correct with my mini example. It works. That is frustrating.

If I press F9 on my files, it fails with an empty window. But now I found the problem.

My bib file starts with:

% Encoding: ISO-8859-1

@String{PHZH = {Pädagogische Hochschule Zürich}}

If I convert the file to UTF-8, it works but all resources that contains german umlauts gets rendered wrong then. It seems that this is a bug in python not able to handle different encodings correctly.

If I set let g:Tex_UsePython = 0 in vimrc, it also works for me. However, I still see that as a bug.

@gerw
Copy link
Contributor

gerw commented May 2, 2021

Can you post your bib file (or a minimal one)? For me, it also works with an iso-encoded bib file. Do you use python2 or python3 within vim (:echo Tex_HasPython)?

@gerw
Copy link
Contributor

gerw commented May 2, 2021

(Btw: currently, latex-suite assumes that the bib-file is utf-8 encoded)

@mowgli
Copy link

mowgli commented May 2, 2021

:echo Tex_HasPython gives 3.
And the bib file is explicitly marked as latin1. Anything else would not work here.

I cannot upload a bib file here.
So this is it (latin1 encoded):

% Encoding: ISO-8859-1

@String{PHZH = {Pädagogische Hochschule Zürich}}

@Book{spiegel2018,
  author         = {Hartmut Spiegel and Christoph Selter},
  date           = {2018},
  title          = {Kinder \& Mathematik},
  edition        = {10},
  foreword       = {Ranga Yogeshwar},
  isbn           = {3-7800-5238-5},
  language       = {german},
  location       = {Seelze},
  pagetotal      = {112},
  publisher      = {Kallmeyer},
  subtitle       = {Was Erwachsene wissen sollten},
  ean            = {978-3-7800-5238-4},
  groups         = {Mathe},
  keywords       = {qualityAssured, read},
  qualityassured = {qualityAssured},
  readstatus     = {read},
}

@Book{gallmann2001,
  author    = {Gallmann, Peter},
  date      = {2001},
  title     = {Deutsche Grammatik},
  isbn      = {3-906718-54-9},
  location  = {Zürich},
  publisher = {Lehrmittelverlag des Kantons Zürich},
  groups    = {Deutsch},
}

@gerw
Copy link
Contributor

gerw commented May 2, 2021

I have pushed a small fix. Now, if decoding the bib file with utf-8 fails, we try again with latin1. Does it work for you?

@mowgli
Copy link

mowgli commented May 2, 2021

Great! Works fine for me.

I hope, that the issue of the OP (@yipeah) is the same and is fixed too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants