Giter Site home page Giter Site logo

latex-environment's People

Contributors

cderv avatar dragonstyle avatar jjallaire avatar nenuial avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

latex-environment's Issues

Arguments in commands?

It seems that you have enabled arguments of environments, but not for commands? I'm trying to find a way to create this type of latex output:

\colorbox{red}{This text is in a red box}

image

However, the following file creates this output (note the square brackets).

\colorbox[red]{This text is in a red box}
\colorbox[red]{This text is in a red box}    <!-- arguments are ignored -->
---
title: test
format: 
    pdf:
        keep-tex: true
        include-in-header:
            text: |
                \usepackage{xcolor}
filters:
   - latex-environment
commands: 
  - colorbox
---

[This text is in a red box]{.colorbox options="red"}
[This text is in a red box]{.colorbox options="red" arguments="argument"}

Add support for custom LaTeX command associated with an environment

A command may need options.

For example, in an exam class,

\begin{parts}
\part[2] Question 1
\part[3] Question 2
\end{parts}

One possible suggestion is

:::{.parts}
[]{.part options="2"} Question 1
[]{.part options="3"} Question 2
:::

With

local function writeCommands(spanEl)
  if quarto.doc.isFormat("latex") then
    for k,v in pairs(classCommands) do
      if spanEl.attr.classes:includes(k) then
        local result = spanEl.content
        local beginCommand = pandoc.RawInline('latex', '\\' .. pandoc.utils.stringify(v) .. '{')
        local endCommand = pandoc.RawInline('latex', '}')

        local opts = spanEl.attr.attributes['options']
        if opts then
          beginCommand = pandoc.RawInline('latex', '\\' .. pandoc.utils.stringify(v) .. '[' .. opts .. ']{')
        end

        table.insert(result, 1, beginCommand)
        table.insert(result, endCommand)

        return result
      end
    end
  end
end

Originally posted by @kwangkim in #1 (comment)

An extension to do the other way around

Hello,

I would like to know if you could make an extension that is kind of the inverse of the current one. That is, it will convert LaTeX syntax into quarto syntax.

I have a lot of mathematical notes written in LaTeX that I would like to convert to blog posts, and doing a manual conversion would require too much work. It would be great if I could just copy the LaTeX source code to *.qmd files. For example, the extension should make quarto understand the following as a theorem:

\begin{theorem}[My Theorem]\label{th:some_theorem}
This is some theorem.
\end{theorem}

I hope that my request makes sense.

Thank you in advance for your reply!

Wrap latex commands

As stated in #13, I want to use the latex-environment filter to highlight specific parts of my code, using the listings latex package / environment together with colorbox. Per default, all latex code within a listings environment is ignored. However, I can specify an escape character in the package options (see here)

escapechar=⟨character⟩ or escapechar={}
If not empty the given character escapes the user to LATEX: all code between
two such characters is interpreted as LATEX code

So if I set the escapechar = |, everything in between | in my listing environment will be interpreted as latex code. Is there a way to get this input:

:::{.lstlisting}
[one]{.colorbox optons = "gray"}, [two]{.colorbox options = "red"}
:::

to this latex output (note the wrapping |)?:

\begin{lstlisting}
|\colorbox{gray}{one}|, |\colorbox{red}{two}|
\end{lstlisting}

Bug? renaming environments in latex

Dear developpers,

I am unsure if I hit a bug or if this works the way it should and I am using it in the wrong way.

I would like to have a .column div in a .qmd file be converted to a minipage environment in latex and I thought this should work using this extension by using:

environments:
  - column: minipage

However this does not produce any envs in latex.

Weirdly,

environments:
  - minipage: column

produces a column in latex

I found a work-around by adding 2 classes to my div :::{.column .minipage arguments="0.3\textwidth"}

Quarto latex stop working on Mac OS

Hi!
This quarto extension has stop working for me for some reason. When I try to run the example code I get this error

Error running filter _extensions/quarto-ext/latex-environment/latex-environment.lua: ...sions/quarto-ext/latex-environment/latex-environment.lua:66: attempt to call a nil value (field 'is_format') stack traceback:

I don't know how to code in Lua, but tracing the history of the commits I found that recently the following line has changed

if quarto.doc.isFormat("latex") then
# to
   if quarto.doc.is_format("latex") then

if I remove this change (to the old isFormat ) everything works as usual.
I have the latest version of quarto installed, running on vscode with the quarto extension v1.46.0.

onlyenv enironment

Can this filter be used for the following environment?

\begin{onlyenv}<⟨overlay specification⟩>
⟨environment contents⟩
\end{onlyenv}

please let me know

Supports setting attributes on the environment

Some LaTeX environment will need to have attributes set, not only a class equivalent.

See https://bookdown.org/yihui/rmarkdown-cookbook/custom-blocks.html for how it works in R Markdown.

We could port the idea and do

:::: {.center}

::: {.minipage latex="{.5\linewidth}"}
This paragraph will be centered on the page, and
its width is 50% of the width of its parent element.
:::

::::

aim is to write

\begin{center}
\begin{minipage}{.5\linewidth}
This paragraph will be centered on the page, and
its width is 50\% of the width of its parent element.
\end{minipage}
\end{center}

We could me more precise on the attribute name, but latex clearly means this is to be used only with LaTeX. We would for sure ignore for HTML this attribute.

We also did also made soemthing generic where you need to add the brackets as an environement could be (more on that in https://tex.stackexchange.com/a/302040/209358)

\begin{foo}[option]{argument}
body
\end{foo}

which would be written

::: {.foo latex="[option]{argument}"}
body
:::

Anyway, happy to port the feature here. Just wanted to discuss with you what you think is the best way to express that on the custom div.

Error : Could not find executable

I have installed the extension, but I get the error saying

Error running filter /opt/quarto/share/filters/main.lua:
Error running filter /home/../Documents/latex-environment:
Could not find executable /home/../Documents/latex-environment
stack traceback:
/opt/quarto/share/filters/main.lua:4026: in function </opt/quarto/share/filters/main.lua:4005>
[C]: in ?
[C]: in method 'walk'
/opt/quarto/share/filters/main.lua:171: in function 'run_emulated_filter'
/opt/quarto/share/filters/main.lua:449: in local 'callback'
/opt/quarto/share/filters/main.lua:454: in upvalue 'run_emulated_filter_chain'
/opt/quarto/share/filters/main.lua:495: in function </opt/quarto/share/filters/main.lua:476>
stack traceback:
/opt/quarto/share/filters/main.lua:171: in function 'run_emulated_filter'
/opt/quarto/share/filters/main.lua:449: in local 'callback'
/opt/quarto/share/filters/main.lua:454: in upvalue 'run_emulated_filter_chain'
/opt/quarto/share/filters/main.lua:495: in function </opt/quarto/share/filters/main.lua:476>

I have installed the extension and it says successfully installed. Please help what can be done here. Even the example code does not work.

Prevent quarto filters

This is a superb extension which I use often. Thank you for your great work.

I'm trying to use the extension to highlight specific parts in code blocks. My starting point is just to create a code block using the latex listings package.

---
title: test
format: 
    pdf:
        keep-tex: true
        include-in-header:
            text: |
                \usepackage{listings}
filters:
   - latex-environment
environments: [lstlisting]
---

:::{.lstlisting}
    Paired t-test

data: blume$a and blume$b
:::

The desired latex output:

\begin{lstlisting}
    Paired t-test

data: blume$a and blume$b
\end{lstlisting}

The created output:

\begin{lstlisting}

\begin{verbatim}
Paired t-test
\end{verbatim}

data: blume\(a and blume\)b

\end{lstlisting}

I'm guessing quarto ran its own filter over the code, turning the indented Paired t-test to verbatim and turning blume$a to blume\(a. Is there a way to prevent quarto from doing this?

some glitch when working with latex package siunitx

When using commands \si{} in siunitx, content \si{\meter\cubed}, [\meter\cubed]{.si}, \si{m^3}, [m^3]{.si} produed
image.

The last one is different from the first three. It seems somewhere did not convert the ^3 correctly.

Error with empty div

First, thanks for developing latex-environment!

I'm getting an error when the div is empty in the Quarto document, like this:

::: {.sumario}
:::

and in the LaTeX template:

\newenvironment{sumario}{
\thispagestyle{empty}
\singlespacing
\listoffigures
\newpage
\listoftables
\newpage
\tableofcontents
}{\pagebreak}

The error is:

Error running filter quarto-ext/latex-environment/latex-environment.lua:
latex-environment/latex-environment.lua:87: attempt to index a nil value (field 'integer index')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.