Just use divs for that: ::: hint Whatever ::: Now, you can use a filter like the one below (posted by BPJ at some point). This will check each div whether it has one of the classes defined in ENV_CLASSES. If yes, it will insert an appropriate raw block. ```lua ENV_CLASSES = { 'intro', 'question', 'solution', 'hint', 'definition', 'whatever'} local function latex(s) return pandoc.RawBlock('latex', s) end local function get_env_class(elem) if elem.classes then for i = 1, #elem.classes do for j = 1, #ENV_CLASSES do if elem.classes[i] == ENV_CLASSES[j] then return ENV_CLASSES[j] end end end else error('function has_class used on an element of type ' .. elem.t .. ' that cannot have classes.') end end function Div(el) local env_class = get_env_class(el) -- nil if there is none if env_class then -- false if env_class is nil return { latex('\\begin{'.. env_class..'}'), el, latex('\\end{'.. env_class..'}') } end end function Span(el) if el.classes[1] == 'speaker' then return pandoc.RawInline('latex', '\\speaker{'..el.content..'}') end end ``` Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Im Auftrag von Stefan Schroeder Gesendet: Donnerstag, 2. Juni 2022 10:18 An: pandoc-discuss Betreff: How to make my latex environment accessible from markdown via short-code? I am converting markdown to pdf via latex using my own template. In the template I have defined a new environment called 'hint' that is like a call-out. This works: --- ```{=latex} \begin{hint} ``` Lorem ipsum dolor sit amet, ```{=latex} \end{hint} ``` --- The Lorem text appears in the callout-environment. I want to make the environment accessible more conveniently via a short-code. I have created a new lua-filter, 'hint.lua' that I successfully include: return { { Str = function (elem) if elem.text == "{{hint_end}}" then return pandoc.Str("```{=latex}\n\\end{guidehint}\n```\n") elseif elem.text == "{{hint_begin}}" then return pandoc.Str "```{=latex}\\begin{guidehint}```" else return elem end end, } } But when I use it, the macro-text will be included literally: {{hint_begin}} Neque porro quisquam est, {{hint_end}} The code is not interpreted to end up being proper Latex, but it's escaped somehow to become a string literal. Thus my output looks like this: “‘{=latex}\begin{hint}“‘ Neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit “‘{=latex} \end{hint} “‘ How do I make the short-code to get access to my own environments? PS. If there are different apporaches, that'll be nice as well. Thanks Stefan -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/4de0a599-a196-438a-928c-b0895b35afb6n%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/cc1c350768424985bb0f5c9380386904%40unibe.ch.