Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Rendering pseudocode in math blocks #1496

Closed
thomas10011 opened this issue May 1, 2024 · 3 comments
Closed

[Feature]: Rendering pseudocode in math blocks #1496

thomas10011 opened this issue May 1, 2024 · 3 comments
Labels

Comments

@thomas10011
Copy link

想要的功能 | What feature do you want?

Thanks for creating this wonderful theme. I'd like to request for a new feature of pseudocode math block rendering.

Since most of markdown editors (e.g. typora, obisidian) have supported the pseudocode code block like below:

```pseudo
    \begin{algorithm}
    \caption{Quicksort}
    \begin{algorithmic}
      \Procedure{Quicksort}{$A, p, r$}
        \If{$p < r$}
          \State $q \gets $ \Call{Partition}{$A, p, r$}
          \State \Call{Quicksort}{$A, p, q - 1$}
          \State \Call{Quicksort}{$A, q + 1, r$}
        \EndIf
      \EndProcedure
      \Procedure{Partition}{$A, p, r$}
        \State $x \gets A[r]$
        \State $i \gets p - 1$
        \For{$j \gets p$ \To $r - 1$}
          \If{$A[j] < x$}
            \State $i \gets i + 1$
            \State exchange
            $A[i]$ with $A[j]$
          \EndIf
        \State exchange $A[i]$ with $A[r]$
        \EndFor
      \EndProcedure
      \end{algorithmic}
    \end{algorithm}
``` /* end of code block */

We could use pseudocode.js to render it into math block, the output of this code snippet should be like:

image

useful reference: https://zjuguoshuai.gitlab.io/2019/04/26/blog-pseudocode.html

@jerryc127
Copy link
Owner

what is pseudocode ? mathjax ?

@thomas10011
Copy link
Author

thomas10011 commented May 8, 2024

From wiki: https://en.wikipedia.org/wiki/Pseudocode

In computer science, pseudocode is a description of the steps in an algorithm using a mix of conventions of programming languages (like assignment operator, conditional operator, loop) with informal, usually self-explanatory, notation of actions and conditions.

Basically it's used to describe algorithm in most academic papers and books, and it's supported by latex softwares. For instance, the pseudocode in the picture I sticked above described the quick sort alogrithm. But mathjax currently can't render the pseudocode.

Copy link

github-actions bot commented Jun 8, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants