Not an immediate concern: Markdown notes with latex -> PDF

What I’m trying to do

I am trying to export my markdown notes which include latex to PDF as they look in Obsidian.

For example, I could have a section that looks like this:

With the latex looking like this:

\text{Let } x \text{ and } y \text{ be two arbitrary odd integers.}\
\text{We will show that } x * y \text{ is an odd integer.}\
\text{Since } x \text{ is odd, there is an integer } j \text{ such that:} \
x = 2j + 1 \
\text{Since } y \text{ is odd, there is an integer } k \text{ such that:} \
y = 2k + 1 \
\text{When we multiply } x \text{ and } y \text{ we get:} \
x * y = (2j + 1) * (2k + 1) = 4jk + 2j + 2k + 1\
\text{We can factor out 2 to get:}\
x * y = 2(2jk + j + k) + 1 \
\text{Since 2(2jk + j + k) is an even integer, 2(2jk + j + k) + 1 is odd.}\
\text{Thus, the product of two odd integers } x \text{ and } y \text{ is odd.}

And I would like to get a PDF of the entire thing were the latex is rendered just like obsidian renders it, but in PDF and through Pandoc.

Things I have tried

I installed Pandoc and configured it as such:

Pandoc Path: /opt/homebrew/bin/pandoc

PDFLatex Path: /usr/local/texlive/2023/bin/universal-darwin/pdflatex

Exporting any files that just contain inline latex $…$, or single lines of blocks like:
3x = 2y

However, rendering sections of multiple lines with:

  • begin{gather*}
  • begin{gather}
  • begin{align}
  • etc…

Give the following error:

Screenshot 2024-01-30 at 10.33.27 AM

As the error suggests, Pandoc might be trying to render the entire thing as if it were just a latex document with the traditional formatting i’ve found in forums; however, this does not work for my purposes and, after hours of messing around, I have not managed to figure it out.

However, one day I woke up and just doing the regular:
Screenshot 2024-01-30 at 10.36.42 AM
Worked out of nowhere.

I have no idea what changed since this did not work before (it just generated plain latex).

So, sure, this works but it does not has the customizability I have seen Pandoc allows. Nor do I know why it works. I would like to know how to do it using Pandoc just in case, since that tool is pretty ubiquitous. Has anyone managed to make it work using it?