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

✨ Feature: pylatexenc as latex renderer #271

Closed
Reledia opened this issue Jan 30, 2025 · 5 comments · Fixed by #266
Closed

✨ Feature: pylatexenc as latex renderer #271

Reledia opened this issue Jan 30, 2025 · 5 comments · Fixed by #266
Labels
enhancement New feature or request

Comments

@Reledia
Copy link

Reledia commented Jan 30, 2025

🔖 Feature description:

Hello,
coming from MeanderingProgrammer/render-markdown.nvim, I personally appreciate more the features supported by pylatexenc (like & to align fixed points in multi-line equations, support of \quad \frac \mbox ...).

📂 Possible solutions:

This said, I do actually prefer your solution for ^n and _n, so what I am really asking for is either feature parity or the possibility to switch to pylatexenc (with the output replacing the line as the native solution)

🧾 Feature reference:

MeanderingProgrammer/render-markdown.nvim

@Reledia Reledia added the enhancement New feature or request label Jan 30, 2025
@OXY2DEV
Copy link
Owner

OXY2DEV commented Jan 30, 2025

the possibility to switch to pylatexenc

I was originally going to slap it in and call it a day but,

  1. It didn't improve readability(at least for me). When I tried using it, I was was struggling to differentiate between the preview text and the latex blocks themselves.
  2. It breaks nested items(e.g. block quote markers, list item indentations etc.)
  3. Stuff like \frac{}{} kinda sucks as they don't show which part of the code is being fractioned.
  4. I don't really do much python so I was unsure about the implementation details.

I am still skeptical about using it(pylatexenc) as I generally prefer not replying on external tools. But if there's more people who need that then I have no problem adding support.


I am really asking for is either feature parity

I have no issues adding feature parity. But I don't know which commands are used commonly and what they look like (I have never used $LaTeX$ before).

So, unless somebody can point to what commands should be added I can't do much on my own.


You can also add your own command previews like so(this is for \quad),

local quad = {                                                                                            condition = function (item)
        --- Only show preview                                                                                 --- If \quad receives
        --- a single argument.
        return #item.args == 1;
    end,

    on_command = {                                                                                            --- Hide \quad part.
        conceal = ""
    },

    on_args = {
        {
            on_before = function (item)
                --- Hide {
                return {
                    end_col = item.range[2] + 1,
                    conceal = "",

                    virt_text_pos = "inline",
                    virt_text = { { "    " } }
                };
            end,

            --- Change the position of the `after`
            --- extmark.
            --- Needed to hide }
            after_offset = function (range)
                return { range[1], range[2], range[3], range[4] - 1 };
            end,

            on_after = function (item)
                --- Hide }
                return {
                    end_col = item.range[4],
                    conceal = ""
                };
            end
        }
    }
};

require("markview").setup({
    latex = {
        commands = {
            ["quad"] = quad
        }
    }
});

@Reledia
Copy link
Author

Reledia commented Jan 30, 2025

Thanks for the example, I don't think I found it in the docs for the latex section.

About the commands, I'm not a latex expert either, but I would check out the ones I mentioned and possibly all the math related ones (like logic operators), text boxes and the environments like aligns and equations.

Additionally, can I ask for more examples about how to modify the ^n and _n rendering? I like the idea, but I found the colours and size to be off for my case

@OXY2DEV
Copy link
Owner

OXY2DEV commented Jan 30, 2025

Thanks for the example, I don't think I found it in the docs for the latex section.

There's an entire section just for LaTeX commands

ask for more examples about how to modify the ^n and _n.

You unfortunately can't. There's no way to render subscript & superscript text. The plugin just uses symbols that look-alike.

So, depending on the font they would look off.

I will add an option to only use ↑() instead.

@Reledia
Copy link
Author

Reledia commented Jan 30, 2025

There's an entire section just for LaTeX commands

I am indeed stupid, thanks for the patience.

We can close the issue I assume, then

@OXY2DEV OXY2DEV closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2025
@OXY2DEV
Copy link
Owner

OXY2DEV commented Jan 30, 2025

You can now do latex = { subscripts = { fake_preview = false } } to disable those symbols.

See wiki

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

Successfully merging a pull request may close this issue.

2 participants