James-Yu / LaTeX-Workshop

Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
MIT License
10.42k stars 519 forks source link

Support for label/ref commands provided by zref #4261

Closed Yarakashi-Kikohshi closed 1 month ago

Yarakashi-Kikohshi commented 2 months ago

Pre-checks*

The Missed*

\zlabel provided by zref does not have “label name completion” and “syntax highlighting” like other \labels.

Additionally, syntax highlighting for \ref accepts variations of this such as \zref, but syntax highlighting for \zref with options (\zref[option]{foo}) does not work.

\label{foo}
\zlabel{foo}

\zref{foo}
\zref[option]{foo}

image

Anything Else?

None.

Version

James-Yu commented 1 month ago

I confirm that neither \label nor \zlabel have label name auto-completion. Can you elaborate on your request? Either macro should just define a new label, instead of referencing one.

The highlighting for \ref[a]{b} and \zref[a]{b} are the same. Are you requesting a same colorization with \ref{b}?

\label{a} and \zlabel{a} are colorized differently. We have outsourced our LaTeX syntax highlighting grammar to vscode-latex-basics, could you please post your issue there and clarify what behaviour you expect?

Yarakashi-Kikohshi commented 1 month ago

I apologize for my misleading and ambiguous explanation.

I confirm that neither \label nor \zlabel have label name auto-completion. Can you elaborate on your request?

By “label name completion” I was referring to the meaning that labeling by \zlabel is not reflected in the auto-completion of labels in \ref.

In other words, when you use \zlabel{foo}, foo is not displayed as a candidate in \ref. Since \zlabel is a command for cross-referenced labels like \label, I would like to see labels by \zlabel also displayed as candidates in \ref.

Are you requesting a same colorization with \ref{b}?

Yes.

I think that \zref and \zlabel with options should be the same color syntax highlighting as \ref and \label. I will submit this as an issue to vscode-latex-basic later.

James-Yu commented 1 month ago

You can use latex-workshop.intellisense.label.command to include zlabel.

For highlighting, please create an issue in the other repo.

Yarakashi-Kikohshi commented 1 month ago

I thought I had some grasp of this extension, but I did not know about this feature. I should have read the wiki more before posting.

In response to your comment, I have added zlabel as follows.

  "latex-workshop.intellisense.label.command": [
    "label",
    "zlabel",
    "linelabel"
  ]

However, the configuration of this setting may not be reflected. Am I doing something wrong?

\documentclass{article}
\usepackage{zref}
\begin{document}

\begin{figure}
  FOO
  \caption{foo}
  \label{fig:foo}
\end{figure}

\begin{figure}
  BAR
  \caption{bar}
  \zlabel{fig:bar}
\end{figure}

\ref{fig:}

\end{document}

image

James-Yu commented 1 month ago

If it won't work, try reload vscode.

image
Yarakashi-Kikohshi commented 1 month ago

I reloaded many times and the result did not change, but when I added zlabel to latex-workshop.view.outline.commands, it worked! (I got the idea from your screenshot.)

Thank you very much for your kind attention. I apologize for the trouble I have caused you.

James-Yu commented 1 month ago

Right, I pushed another fix that influences this issue. Will go live in the next release.