learning-notes icon indicating copy to clipboard operation
learning-notes copied to clipboard

在 `minted` 代码块中输入两个 `$` 会出错误吗?怎么解决?

Open daa233 opened this issue 7 years ago • 0 comments

例如下面的代码:

\begin{minted}[mathescape, gobble=2, fontsize=\scriptsize, framesep=2mm]{c++}

    int f(char str[], int index, int state)
    {
        if (strlen(str) <= index) {
            return -1;
        } else {
            if (str[index] == '(') {
                int girlIndex = f(str, index+1, state-1);   // 尝试寻找下一个能匹配的右括号的位置
                if (girlIndex > 0) {    // 的确存在匹配的右括号,将其中匹配的左括号置为' '
                    str[index] = ' ';
                    return f(str, girlIndex+1, state);  // 从匹配的右括号下一位置继续查验
                } else {
                    str[index] = '$';   // 不存在匹配的右括号,返回-1, 并将此左括号置为'$'
                    return -1;
                }

\end{minted}

daa233 avatar Oct 29 '17 14:10 daa233