It depends on what you are using to convert your Markdown to PDF.
I had a similar issue last week and struggled to convert my engineering report with mathematical equations (latex) from Markdown to PDF and share with our team. I tried with multiple tools but most were not providing an output with style similar to VsCode or even GitHub.
Dillinger, Typora etc. None of them presented an output I was looking for.
But this Markdown to PDF converter gave a preview that's close to what I was looking for. My colleagues liked the format of the report.