Skip to content
Discussion options

You must be logged in to vote

The following workaround leads to Pandoc unfolding latex_macros for HTML output (which is necessary for macros to affect KaTeX math), and to Pandoc leaving the macro processing to LaTeX for PDF.

---
title: "Conditional Macros"
format:
  html:
    html-math-method: katex
  pdf:
    from: markdown-latex_macros
---

::: {.content-visible when-format="html"}
\providecommand{\mymacro}{\texttt{HTML version of macro}}
<!-- this version of the macro will be unfolded by Pandoc's latex_macros filter, which we deactivate for PDF  -->

(This is HTML output.)
:::

::: {.content-visible when-format="pdf"}
\providecommand{\mymacro}{\texttt{PDF version of macro}}
<!-- this version of the macro will be un…

Replies: 4 comments 9 replies

Comment options

You must be logged in to vote
7 replies
@mcanouil
Comment options

@mcanouil
Comment options

@mcanouil
Comment options

@benkeks
Comment options

@mcanouil
Comment options

Comment options

You must be logged in to vote
2 replies
@mcanouil
Comment options

@cderv
Comment options

Answer selected by benkeks
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
latex LaTeX engines related libraries and technologies html Issues with HTML and related web technology (html/css/scss/js) math any issue related to math support in specific formats
3 participants