ytliu74 / obsidian-pseudocode

An obsidian plugin that helps to render a LaTeX-style pseudocode inside a code block.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

algorithm2e package support

sherlcok314159 opened this issue · comments

I failed to use this with algorithm2e package while it works fine with my LaTeX. The code is below:

\begin{algorithm}
    \caption{Training Perceptron}\label{algorithm}
    $\mathbf{w} \gets \mathbf{0}$\\
    \While{true}{
        $m \gets 0$\\
        \ForAll{$(x^{(i)}, y^{(i)}) \in \mathcal{D}$}{
            \If(// mis-classified){$y^{(i)}(\mathbf{w}^{\mathbf{T}}x^{(i)}) \le 0$}{
                $\mathbf{w} \gets \mathbf{w} + y^{(i)}x^{(i)}$\\
                $m \gets m + 1$\\

            }
        }
        \If(// all are classified correctly){$m = 0$}{
            break\\
        }
    }
    \end{algorithm}

Due to the limitation of pseudocode.js, you can only input your code as:

\begin{algorithm}
\caption{Algo Caption}
\begin{algorithmic}
% Here is your pseudocode
\end{algorithmic}
\end{algorithm}

For more examples, please refer to this link. Sorry for the inconvenience, this plugin and dependent library try to typeset pseudocode beautifully to HTML, instead of embedding a LaTeX compiler, so there are some limitations.