Skip to content

TeX highlighting is lost for tikz knitr engine in Visual Editor #13388

Open

Description

@cderv

System details

RStudio Edition : Desktop [Open Source]
RStudio Version : 2023.9.0.233
OS Version      : Windows 10 x64 (build 22621)
R Version       : R version 4.2.2 (2022-10-31 ucrt)

Steps to reproduce the problem

Take this document using tikz engine

---
title: "Untitled"
engine: knitr
format: pdf
---

```{tikz}
#| label: fig-tikz-plot3d
#| fig-cap: TikZ
#| engine-opts: !expr list(extra.preamble=c("\\usepackage{pgfplots}","\\pgfplotsset{width=7cm,compat=1.18}"))
\begin{tikzpicture}
\begin{axis}[
    hide axis,
    colormap/viridis,
]
\addplot3[
    mesh,
    samples=50,
    domain=-8:8,
]
{ sin(deg(sqrt(x^2+y^2)))/sqrt(x^2+y^2) };
\addlegendentry{$\frac{\sin(r)}{r}$}
\end{axis}
\end{tikzpicture}
```

Describe the problem in detail

In source mode it seems we get LaTeX highlighting as expected
image

In visual mode we lost it
image

Describe the behavior you expected

Expected behavior is that visual mode highlight the same. It should be TeX highligting.

Possible behavior:

  • Source mode does not highlight as TeX either... and the issue is maybe a feature request to highlight Tikz engine as a TeX block.

Something like in visual mode

``` tex
\begin{tikzpicture}
\begin{axis}[
    hide axis,
    colormap/viridis,
]
\addplot3[
    mesh,
    samples=50,
    domain=-8:8,
]
{ sin(deg(sqrt(x^2+y^2)))/sqrt(x^2+y^2) };
\addlegendentry{$\frac{\sin(r)}{r}$}
\end{axis}
\end{tikzpicture}
```

Related to

Activity

  1. added
    new
    visual markdown
    and removed
    new
    on Aug 1, 2023
  2. github-actions commented on Jan 30, 2024

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.

  3. added
    stale
    on Jan 30, 2024
  4. cderv commented on Jan 30, 2024

    @cderv
    CollaboratorAuthor

    Still happening also with latest daily

    RStudio Edition : Desktop [Open Source]
    RStudio Version : 2024.4.0.327
    OS Version      : Windows 11 x64 (build 22631)
    R Version       : R version 4.3.2 (2023-10-31 ucrt)
    
  5. removed
    stale
    on Jan 31, 2024
  6. added this to the Chocolate Cosmos milestone on Jan 31, 2024
  7. self-assigned this
    on Feb 2, 2024
  8. kevinushey commented on Feb 2, 2024

    @kevinushey
    Collaborator

    It looks like we're highlighting the code as though it were R code in source mode, which isn't really ideal either! I'll see if we can specifically wire up tikz to LaTeX highlight rules.

  9. kevinushey commented on Mar 14, 2024

    @kevinushey
    Collaborator

    We now have proper highlighting for tikz in source mode via a0cc8d1#diff-6f2fed2b6aff3419cf924d2f0a084c4f548a21ab075e912d317d9e7ce5c76ce7R311, but we haven't yet done the necessary wiring for visual mode.

  10. removed their assignment
    on Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugvisual markdown

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions