Debdeep Bhattacharya

View My GitHub Profile

All Titles

Total: 25

Writing with markdown and TeX

5 Apr 2025

[\newcommand{\xx}{\mathbf{x}} \newcommand{\R}{\mathbb{R}} \newcommand{\ww}{\boldsymbol{\omega}}]

[\begin{CD} A @<<< B @>>> C
@. @| @AAA
@. D @= E \end{CD}]

New command \(\xx\) and \(\R\) and $\R$ and $\xx$ and so on and so forth and $\ww$ and $\lesssim$ $\textcolor{blue}{Hello}$ and $\boldsymbol{\omega}$

Inline math: \(x^2\) vs $x^2$

vs

[\begin{align} x^2 \end{align}]

vs

\begin{align} x^2 \end{align}

Tex and markdown conversion to html with pandoc

:setfiletype pandoc.tex
---
title: Readme
author: Author
header-includes: |
    \usepackage{amsmath, amssymb, amsthm, amsfonts, color, bm}

    \newcommand{\R}{\mathcal{R}}
    \newcommand{\ww}{\boldsymbol{\omega}}
    \newcommand{\xx}{\mathbf{x}}
---

Converting a tex file into html pandoc file.tex -o file.html uses unicode by default to render math symbols. We need to use mathjax for a nicer rendering. Other options are

--mathml, --webtex, --mathjax, --katex

and demos can be found in pandoc demos.

According to pandoc documentation One need to specify the url of the .js file that would be used to convert math into mathjax. By default pandoc uses some link form some content delivery network (CDN), which does not work on firefox at the first attempt. So we can specify the url like this:

pandoc math.text -s --mathjax=https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js -o   mathMathJax.html

There are other CDN locations on mathjax documentation from sites like

pandoc README.md -s --mathjax=https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js -o   README.html

LaTeX writing guide

We want our .md file to convert to pdf or tex without much hassle. While using mathjax, a few things to remember for a quick conversion.

Diagrams

My observation is that using a freehand drawing tool like inkscape takes less time and provides more flexibility for creating diagrams. Markdown-friendly tools like mermaid required additional set up and does not seem to support latex within diagram. Maybe once can use latex tikz diagrams within markdown, but the whole point was to move away from programmable diagrams. Still:

Install pandoc filter for mermaid from git using

npm install --global mermaid-filter

Use it with -F in pandoc

pandoc  -F mermaid-filter something.md -o something.html 

A sample block of code

```{.mermaid format=png scale=5 caption='Computational graph'}
%%{init: {'theme':'neutral'}}%%
  graph TD
    a --> b

```

produces a flowchart-like diagram.

Marp and usual markdown

Converting marp-focused .md file into html using pandoc is very glitchy. Few things that do not work so far

Github readme compatibility

The markdown files with header does not render in github webpages, even though both are mathjax.

</p>--> [\newcommand{\xx}{\mathbf{x}} \newcommand{\R}{\mathbb{R}} \newcommand{\ww}{\boldsymbol{\omega}}] [\begin{CD} A @<<< B @>>> C\ @. @| @AAA\ @. D @= E \end{CD}] <p>New command (\xx) and (\R) and $\R$ and $\xx$ and so on and so forth and $\ww$ and $\lesssim$ $\textcolor{blue}{Hello}$ and $\boldsymbol{\omega}$</p> <p>Inline math: (x^2) vs $x^2$</p> <p>vs</p> [\begin{align} x^2 \end{align}] <p>vs</p> <p>\begin{align} x^2 \end{align}</p> <h1 id="tex-and-markdown-conversion-to-html-with-pandoc">Tex and markdown conversion to html with pandoc</h1> <ul> <li>To use latex goodies such…</p> </p>-->


3D plots in python

12 Apr 2022


Python parallel processing with multiprocessing

5 Mar 2022


Common git scenarios

15 Jan 2022


Setting up vim in a local environment

14 Dec 2021


Merging a git branch

13 Nov 2021


Creating git repositories

1 Oct 2021


Vim shortcuts you should be using

23 Nov 2019


Simple chat server and client with netcat

10 Nov 2019


Syntax folding in vim and custom folding for a file

5 Nov 2019


Handy pdf editing tools

3 Oct 2019


A quick guide to managing tasks using taskwarrior

14 Sep 2019


Performing xserver activities through tty or remote ssh shells

2 Sep 2019


Installing and using Cocalc notebook locally

30 Aug 2019 </p>-->


Basics of R

18 Jul 2019


Google drive client (gdrive) for command line

17 Jun 2019


Processes and how to kill them

15 Jun 2019


Handling compressed files without remembering the parameters

12 May 2019


Improving productivity on terminal

11 May 2019


Moving directories to their own partitions

23 Mar 2019


Calculate the size of a directory including its subdirectories

18 Feb 2019


Installing xournal from source and adding useful patches

15 Feb 2019


Create a startup script to mount hard disk drives automatically

14 Feb 2019


Writing a manpage in Linux

9 Feb 2019


Take screenshots (print screen) in Linux using imagemagick

5 Feb 2019