Visual Studio Code for Xelatex latexmkrc 与 Beamer 和 Minted for Musixtex

Visual Studio Code for Xelatex latexmkrc 与 Beamer 和 Minted for Musixtex

需要使用 Beamer 为 Xelatex latexmkrc 配置 Visual Studio Code,并使用 Minted 为 Musixtex 配置 Visual Studio Code。为此,我配置了以下文件:

  1. latexmkrc:

    $xelatex = 'internal musixlatex %R %O %S';
    push @generated_exts,"mx2";
    push @generated_exts,"mx1";
    
    sub musixlatex {
       my $root = shift;
       # Define root filename for the mx1 and mx2 files
       # Note that $aux_dir1 includes directory separator
       #      and it equals $out_dir1 if only the out_dir is set.
       my $mx = "$aux_dir1$root";
       my @args = @_;
       if ( $pass{$rule} <= 1 ) { 
          print "======= FIRST PASS: Deleting '$mx.mx2' =======\n";
          unlink "$mx.mx2"; 
          print "====   Generating '$mx.mx1' then '$mx.mx2' ===\n";
          my $ret = system( "xelatex @args" );
          if ($ret) { return $ret; }
          $ret = system( "musixflx $mx" );
          if ($ret) { return $ret; }
       }
       return system( "xelatex @args" );
    }
    
  2. 设置.json:

    {
        "workbench.colorTheme": "Default Dark+",
        "security.workspace.trust.untrustedFiles": "open",
        "latex-workshop.latex.tools": [{
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "--shell-escape",
                "-xelatex",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        }],
    "editor.accessibilitySupport": "off",
    "chronicler.ffmpeg-binary": "c:\\Users\\Aland\\Downloads/ffmpeg.exe",
    "window.zoomLevel": 1
    }
    
  3. Latex beamer 代码(注意,需要为 Latex 代码配置 minted,并为 Musixtex 进行定制):

    \documentclass[aspectratio=169]{beamer}
    \usepackage{musixtex}
    
    \usepackage{minted}
    \usemintedstyle{borland}
    
    \begin{document}
    
    \begin{frame}[t]
    \frametitle{\large Musixtex code}
    
    \begin{minted}{latex}
        \begin{music}
            \setclef1\treble % Clave de Sol para el Instrumento 1
            \nobarnumbers % Omite la numeración en los compases
            \nostartrule % Inicia sin barra vertical
            \startextract %inicia el fragmento musical
            %Primer compás
            \NOTEs \wh{ghijkl^mn}  \en\setdoubleBAR
            \endextract % Se finaliza el fragmento musical
          \end{music}
    \end{minted}
    
    \end{frame}
    
    \end{document}
    

注意:我已经安装了 pygmentize,它运行良好。

答案1

fragile如果您有像源代码列表这样脆弱的内容,则需要使用框架选项:

% !TeX program = txs:///arara
% arara: xelatex: {synctex: on, interaction: nonstopmode, shell: yes}
\documentclass[aspectratio=169]{beamer}
\usepackage{musixtex}

\usepackage{minted}
\usemintedstyle{borland}

\begin{document}

\begin{frame}[fragile,t]
\frametitle{\large Musixtex code}

\begin{minted}{latex}
    \begin{music}
        \setclef1\treble % Clave de Sol para el Instrumento 1
        \nobarnumbers % Omite la numeración en los compases
        \nostartrule % Inicia sin barra vertical
        \startextract %inicia el fragmento musical
        %Primer compás
        \NOTEs \wh{ghijkl^mn}  \en\setdoubleBAR
        \endextract % Se finaliza el fragmento musical
      \end{music}
\end{minted}

\end{frame}

\end{document}

在此处输入图片描述

相关内容