用於將「人類」文字轉換為合理的 LaTeX 程式碼的類似 Markdown 的工具?

用於將「人類」文字轉換為合理的 LaTeX 程式碼的類似 Markdown 的工具?

在我的理想世界裡,能夠寫出類似的東西

So here are the steps:
- So now we define x^* = min { x | sum_kk ||f(x_kk^20)|| } and then do blah
    - But this requires another indented bullet point with a couple equations:
        a = 1/2 + 1
        b = c + d
- Now I have another step

並自動將其轉換為 LaTeX 中相當相似的內容,例如:

So here are the steps:
\begin{itemize}
    \item So now we define $x^* = \min \left\{ x \middle| \sum_{kk} \lVert f(x_{kk}^{20}) \rVert \right\}$ and then do blah
        \begin{itemize}
            \item But this requires another indented bullet point
            \begin{align*}
                a &= 1/2 + 1  \\
                b &= c + d
            \end{align*}
        \begin{itemize}
    \item Now I have another step
\end{itemize}

我意識到可能沒有工具可以做到這一點確切地我想要什麼,但是有沒有任何工具可以幫助我做任何事情,甚至像這樣遠程,幫助我節省我的手指並減少打字?

筆記:

  1. 我是不是嘗試轉換手寫體。已經有另一個問題了。

  2. 「正確」的輸出是主觀的。沒關係。我只是想要一些合理的東西。

  3. 如果需要,我可以輸入$...$\以及所有內容,但我想盡可能少地輸入。
    經過遠的鍵入最痛苦的是\begin{ENVIRONMENT}...\end{ENVIRONMENT}\left...\middle...\right、 和這類冗長的結構。

答案1

正如我們在評論和聊天中討論的那樣,沒有辦法以明確的方式解析數學。因此,大多數將某些內容轉換為 LaTeX 的工具都不會實現任何複雜的數學解析技術,如您的問題所示。

然而,該pandoc工具接受內聯 LaTeX 數學。考慮以下另存為的範例test.md

So here are the steps:

- So now we define $x^* = \min\left\{ x \middle| \sum_{kk} \|f(x_{kk}^{20})\| \right\}$ and then do blah
    - But this requires another indented bullet point with a couple equations:
      \begin{align*}
        a &= 1/2 + 1 \\
        b &= c + d \\
      \end{align*}
- Now I have another step

現在您可以將此pandoc程式碼片段轉換為 LaTeX。

pandoc -f markdown -t latex -o test.tex test.md

結果text.tex將有內容

So here are the steps:

\begin{itemize}
\itemsep1pt\parskip0pt\parsep0pt
\item
  So now we define
  $x^* = \min\left\{ x \middle| \sum_{kk} \|f(x_{kk}^{20})\| \right\}$
  and then do blah

  \begin{itemize}
  \itemsep1pt\parskip0pt\parsep0pt
  \item
    But this requires another indented bullet point with a couple
    equations:

    \begin{align*}
        a &= 1/2 + 1 \\
        b &= c + d \\
      \end{align*}
  \end{itemize}
\item
  Now I have another step
\end{itemize}

答案2

事實證明它存在並且被稱為 ASCIIMath

它似乎將 HTML 中的數學轉換為 MathML,供 MathJax 渲染。

之後,如果您確實需要 LaTeX 程式碼,可以使用標準實用程式將 MathML 轉換為 LaTeX。否則,您可以直接使用渲染的輸出。

相關內容