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

ref is not consistent with multiple files #41

Open
FlorianRohm opened this issue Apr 5, 2016 · 3 comments
Open

ref is not consistent with multiple files #41

FlorianRohm opened this issue Apr 5, 2016 · 3 comments

Comments

@FlorianRohm
Copy link

Hi,
I have encountered an issue with the autocompletion of ref and eqref.

suppose I have the following structure:
sections/
| section1.tex
| section2.tex
main.tex

section1.tex

% !TEX root = ../main.tex

\begin{equation}
  \label{eq:1}
  a=b
\end{equation}

% place1

section2.tex

% !TEX root = ../main.tex

\begin{equation}
  \label{eq:2}
  a=b
\end{equation}

% place2

main.tex

\section{Section1}
\label{sec:section1}
\import{sections/}{section1.tex}

\section{Section2}
\label{sec:section2}
\import{sections/}{section2.tex}

% place3

in this layout:
\ref{ at place1 and 2 just suggest the equations of their files, \ref{ at place3 suggests only the section labels.

Funny thing is:
When changing
% !TEX root = ../main.tex
to
%!TEX root = ../main.tex
place1 and 2 suggestions are just the sections, without even the eq: from the own file.

I think this is supposed to be a bug. Expected behaviour from my side would be that the space on the latex magic comments does not matter and everything from all files is included.

I don't know how its handled internally, but you could just parse the aux file of the main.tex for the newlables. There should be the complete list. (Caveat: does not work live, only after compilation)

Thanks in advance,
Flo

Edit:
similar Issues:
#11 , this would explaine the issue with the space if references are handled the same way, but I don't understand enough to explain the rest.

Edit2:
Atom: 1.6.1
Latexer: 0.3.0

@Focus
Copy link
Owner

Focus commented Apr 12, 2016

Thanks for the bug report.

The correct tex directive is %!TEX root = ../main.tex without the space, so the package is functioning properly with that.

The labels are found by reading the files that you have included and opened. There are two bugs here. One is that the \import is not implemented. The second is, like you mentioned, that somehow the eq:1 and eq:2 are being missed. This seems really weird.

Perhaps parsing the aux file might be a good idea. I will have to look into it. In the meantime, if you fancy having a crack, then feel free to submit a PR.

@pafalium
Copy link
Contributor

Hi,
I'm working with a document that has a similar directory structure but does not use import and I'm getting the same issue i.e. the labels from the section files are missing.

Instead of importing the sections in root directly, it uses sections/main.tex as an intermediate.
The directory structure looks like this:

sections/
| main.tex
| sec_1.tex
| sec_2.tex
root.tex

Now, since it uses the include and input commands, all paths are relative to the root file.

I've looked into latexer's code and it appears that my bug is caused by the labels finding code looking for \input/\include'ed files relative to the current file instead of the root file.

@QuentinRoy
Copy link

It would be nice to see support for subfile as well.

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