Skip to content

Yurie/LaTeXTool

LaTeX tools.

Formatter

  • LaTeXFormat[opts_][file_] - format the LaTeX file.

    The file will be formatted firstly by tex-fmt and then successively by the steps controlled by the following options.

    • "Indentation"->4

    • "SurroundEquationWithPercent"->False

      • surround equations with percentage symbol;

      • accepts True of False;

      Code

      %
      \begin{equation}
          a+b
      \end{equation}
      %
      
      \begin{equation}
          a+b
      \end{equation}
      
    • "EquationMarkSpacing"->None

      • adjust spacings before punctuation marks in equation environment;

      • accepts None or one of the followings:

        Code

        {"\\;","\\,","\\:","\\>","\\ "}
        
      • skip equations surrounded by the magic comments

        Code

        % LaTeXFormat-EMS-Off
        ...
        % LaTeXFormat-EMS-On
        

      Code

      \begin{equation}
          a+b
          \, .
      \end{equation}
      
      % LaTeXFormat-EMS-Off
      \begin{equation}
          a+b.
      \end{equation}
      % LaTeXFormat-EMS-On
      
      \begin{equation}
          a+b.
      \end{equation}
      
      % LaTeXFormat-EMS-Off
      \begin{equation}
          a+b.
      \end{equation}
      % LaTeXFormat-EMS-On
      
  • MarkdownFormat[opts_][file_] - format the Markdown file.

    The file will be formatted firstly by AutoCorrect and then successively by the steps controlled by the following options.

    • "SurroundInlineEquationWithBlank"->True

      • surround inline equations with blank;

      • accepts True of False;

      • skip inline equations surrounded by the magic comments

        Code

        <!-- MarkdownFormat-IEB-Off -->
        ...
        <!-- MarkdownFormat-IEB-Off -->
        

      Code

      测试,$a$ 测试
      
      测试,$a$测试
      
    • "SurroundEquationWithEmptyLine"->True

      • surround equations with empty line;

      • accepts True of False;

      Code

      测试
      
      \begin{equation}
          a+b
      \end{equation}
      
      测试
      
      测试
      \begin{equation}
          a+b
      \end{equation}
      测试
      
    • "EquationMarkSpacing"->None

      • similar to the one in LaTeXFormat.

Parser

  • LaTeXParser[opts_][file_] - a simple parser of LaTeX.

    • Parse \newcommand, \newenvironment and \usepackage.

    • To disable parsing of a line, add the magic comment % LaTeXParser-Skip at the end of that line. To disable parsing of a block, use the magic comments:

      Code

      % LaTeXParser-Off
      ...
      % LaTeXParser-On
      
    • The option "SkipType" allows typed magic comments and accepts Automatic|_String|{__String}, where Automatic for non-typed ones.

      For example, the magic comment % LaTeXParser-MathJax-Skip will be triggered by setting the option as "SkipType"->"MathJax".

Other tools

  • MathJaxJSOverwrite[macro_][file_] - overwrite the macros in JSON files used by MathJax.

    • The matching is hinted by the magic comments:

      Code

      // MathJaxJSOverwrite-Macro-Begin
      macros: {
          ...
      },
      // MathJaxJSOverwrite-Macro-End
      

To-do

  • The parser of \newenvironment has not been implemented.