LaTeX Lint
Abstract
This extension provides a LaTeX Linter for .tex and .md files with useful commands for academic writing.

Web Version is also available.
We welcome any kind of feedback, suggestions, and pull requests!
Rules
Here is the list of rules we detect.
- LLAlignAnd (detect
=&, \leq&, \geq&, etc.)
- LLAlignEnd (detect
align environment ends with \\)
- LLAlignSingleLine (detect
align environment without \\)
- LLArticle (detect wrong article usage)
- LLBig (detect
\cap_, \cup_, etc.)
- LLBracketCurly (detect
\max{ and \min{)
- LLBracketMissing (detect
^23, _23, etc.)
- LLBracketRound (detect
\sqrt(, ^(, and _()
- LLColonEqq (detect
:=, =:,::=, and =::)
- LLColonForMapping (detect
: for mapping)
- LLCref (detect
\ref, disabled by default)
- LLDoubleQuotes (detect
“, ” and " )
- LLENDash (detect the dubious use of
-)
- LLEqnarray (detect
eqnarray environment)
- LLFootnote (detect
. + newline + \footnote)
- LLHeading (detect heading level jumps)
- LLJapaneseSpace (detect the lack of space, disabled by default)
- LLLlGg (detect
<< and >>)
- LLNonASCII (detect fullwidth ASCII characters, disabled by default)
- LLPeriod (detect
e.g.)
- LLRefEq (detect
\ref{eq:)
- LLSharp (detect
\sharp, not \#)
- LLSI (detect
KB, MB, GB, etc. without \SI)
- LLSortedCites (detect unsorted cites)
- LLT (detect
^T)
- LLThousands (detect
1,000 etc.)
- LLTitle (detect dubious title case in
\title{}, \section{}, etc.)
- LLUnRef (detect unreferenced figure and table labels)
- LLURL (detect unnecessary info in URLs)
- LLUserDefined (detect Regexes in
latexlint.userDefinedRules)
Please also refer to sample/lint.pdf and our Japanese article (日本語解説記事) if needed.
LLAlignAnd
Detect =& in .tex or .md files.
Use &= or ={}& in the align environment to avoid relation spacing error.

We also detect \neq&, \leq&, \geq&, \le&, \ge&, <&, and >&.
As a limitation of this extension, there are some false positives, such as &= in the table environment.
Ref by Stack Exchange.
LLAlignEnd
Detect align, gather, and other environments end with \\ in .tex or .md files.
This \\ can be unnecessary.
LLAlignSingleLine
Detect align environment without \\ in .tex or .md files.
You should likely use the equation environment.

The spacing of the align environment is different from the equation environment with only one equation.
It is up to you which one to use, but amsmath official documentation suggests using the equation environment for only one equation.
You can rename the command by LaTeX Lint: Rename Command or Label.
LLArticle
Detect wrong article usage in .tex or .md files.
For example, A $n$-dimensional should be An $n$-dimensional (We might add more patterns in the future).
Such error cannot be detected by grammar checkers such as Grammarly, since it contains a math equation.
LLBig
Detect \cap_, \cup_, \odot_, \oplus_, \otimes_, \sqcup_, uplus_, \vee_, and \wedge_ in .tex or .md files.
You should likely use \bigcap, \bigcup, \bigodot, \bigoplus, \bigotimes, \bigsqcup, \biguplus, \bigvee, and \bigwedge instead.

Ref by Stack Exchange.
LLBracketCurly
Detect \max{ and \min{ in .tex or .md files.
You should likely use \max( and \min( instead, or add a space after \max or \min to clarify.

LLBracketMissing
Detect cases such as ^23, _23, ^ab, and _ab in .tex files.
Clarify the scope of the superscript and subscript by adding {} or a space.

LLBracketRound
Detect \sqrt(, ^(, and _( in .tex or .md files.
You should likely use \sqrt{, ^{, and _{ instead.

LLColonEqq
Detect :=, =:, ::=, and =:: in .tex files.
You should likely use \coloneqq, \eqqcolon, \Coloneqq, and \Eqqcolon in the mathtools package instead.

The colon is slightly too low in :=, but vertically centered in \coloneqq according to this.
Ref by Stack Exchange.
Detect : which seems to be used for mapping in .tex or .md files.
You likely want to use \colon instead.

\colon is recommended for the mapping symbol. : is used for ratios, such as 1:2.
In order to detect this pattern, we seek \to,\mapsto and \rightarrow after the :. If there are any of these commands within 10 words after the : and before $ without escaping, we regard the : as a mapping symbol. There are some false positives and negatives.
LLCref
Detect \ref in .tex files.
You should likely use \cref or \Cref in the cleveref package instead.
By default, this rule is disabled by latexlint.disabledRules in settings.json.
We prefer this package because it can automatically add prefixes like "Sec." or "Fig.". We can keep the consistency of the reference format.
For the cleveref package, you can also refer to this page by opt-cp.
LLDoubleQuotes
Detect “, ” and " in .tex files.
These might be used as "XXX" or “XXX”.
Use ``XXX'' instead for double quotation.
As for “XXX”, there is no problem in most cases. We prefer to use ``XXX'' for consistency.
You can also use \enquote{XXX} with the csquotes package.
Ref by Stack Exchange.
LLENDash
Detect the dubious use of hyphens in .tex or .md files.
You should likely use -- for en-dash and --- for em-dash.

Although this rule is not inherent orthographic "correctness", in a lot of cases, the use of an en dash is preferred.
For example, we detect the following.
Erdos-Renyi (random graph, Erd\H{o}s--R\'enyi)
Einstein-Podolsky-Rosen (quantum physics, Einstein--Podolsky--Rosen)
Fruchterman-Reingold (graph drawing, Fruchterman--Reingold)
Gauss-Legendre (numerical integration, Gauss--Legendre)
Gibbs-Helmholtz (thermodynamics, Gibbs--Helmholtz)
Karush-Kuhn-Tucker (optimization, Karush--Kuhn--Tucker)
However, we do not detect the following as an exception.
Fritz-John (optimization, name of a person)
- todo: add more exceptions
We also should use -- instead of - to indicate a range of pages, e.g., 123--456 instead of 123-456. A lot of BibTeX files follow this rule. We do not detect this because it might be just a subtraction.
We use the Regex [A-Z][a-zA-Z]*[a-z], consisting of an uppercase letter, zero or more letters, and a lowercase letter.
We assume that this represents someone's name.
LLEqnarray
Detect eqnarray environment in .tex or .md files.
You should likely use the align environment instead.
It is known that the eqnarray environment is not recommended because it has some spacing issues.
Detect . + newline + \footnote in .tex files.
You should likely add % after . to avoid spacing issues.

LLHeading
Detect improper heading hierarchy in .tex files.
This rule warns when there are jumps in heading levels, such as going directly from \section to \subsubsection without an intermediate \subsection.
The rule checks the following heading levels (in order):
\chapter
\section
\subsection
\subsubsection
LLJapaneseSpace
Detect the lack of space between Japanese characters and math equations in .tex or .md files.
By default, this rule is disabled by latexlint.disabledRules in settings.json.
LLLlGg
Detect << and >> in .tex or .md files.
You should likely use \ll and \gg instead.

We do not detect << like this one.
I like human $<<<$ cat $<<<<<<<$ dog.
LLNonASCII
Detect all fullwidth ASCII characters in .tex or .md files.
We detect the following characters.
!"#$%&'*+-/0123456789:;
<=>?@ABCDEFGHIJKLMNOPQRS
TUVWXYZ[\]^_`abcdefghijk
lmnopqrstuvwxyz{|}~
We use the following Regex.
[\u3000\uFF01-\uFF07\uFF0A-\uFF0B\uFF0D\uFF0F-\uFF5E]
Range U+FF01–FF5E reproduces the characters of ASCII 21 to 7E as fullwidth forms. U+FF00 does not correspond to a fullwidth ASCII 20 (space character), since that role is already fulfilled by U+3000 "ideographic space".
Wikipedia
Plus, U+3000 is used for a fullwidth space.
We do not detect the following characters because they are often used in Japanese documents.
- U+FF08
(
- U+FF09
)
- U+FF0C
,
- U+FF0E
.
If you want to detect all non-ASCII characters, use the following Regex with LaTeX Lint: Add Custom Detection Rule.
[^\x00-\x7F]
\x00 to \x7F are ASCII characters.
For example, you can detect the following Japanese characters.
あア亜、。
LLPeriod
Detect e.g. in .tex or .md files.
You should likely add a comma like e.g., or use e.g.\ to avoid spacing issues.

Ref by Stack Exchange
LLRefEq
Detect \ref{eq: in .tex files.
You should likely use \eqref{eq: instead.
This command automatically adds parentheses around the reference.
LLSharp
Detect \sharp in .tex or .md files.
You should likely use \# instead for the number sign.

\sharp is used for the musical symbol.
LLSI
Detect KB, MB, GB, TB, PB, EB, ZB, YB, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, and YiB without \SI in .tex files.
You should likely use \SI instead, like \SI{1}{\kilo\byte}(10^3 byte) and \SI{1}{\kibi\byte}(2^{10} byte).

| Prefix |
Command |
Symbol |
Power |
| kilo |
\kilo |
k |
3 |
| mega |
\mega |
M |
6 |
| giga |
\giga |
G |
9 |
| tera |
\tera |
T |
12 |
| peta |
\peta |
P |
15 |
| exa |
\exa |
E |
18 |
| zetta |
\zetta |
Z |
21 |
| yotta |
\yotta |
Y |
24 |
It would be better to use \SI for units such as m, s, kg, A, K, mol, and rad.
CTAN: siunitx
LLSortedCites
Detect unsorted multiple citations in .tex files.
Multiple citations like \cite{b,a} will be displayed as [2,1] instead of the sorted order [1,2]. This rule detects such cases and suggests adding the sort option to natbib or using \usepackage{cite}.
This rule only applies when:
- The document uses
\usepackage[numbers]{natbib} without sort option, and
- The document does NOT use
\usepackage{cite} or \usepackage{biblatex}
(This rule might not be accurate.)
LLT
Detect ^T in .tex or .md files.
You likely want to use ^\top or ^\mathsf{T} instead to represent the transpose of a matrix or a vector.

Otherwise, we cannot distinguish between the transpose and the power by a variable T (you can use ^{T} for the power).
Ref by BrownieAlice.
LLThousands
Detect wrongly used commas as thousands separators, such as 1,000 in .tex files.
You should likely use 1{,}000 or use the package icomma.

Ref by Stack Exchange.
LLTitle
Detect dubious title cases in \title{}, \section{}, \subsection{}, \subsubsection{}, \paragraph{}, and \subparagraph{} in .tex files.
For example,
The quick brown fox jumps over the lazy dog
should be
The Quick Brown Fox Jumps Over the Lazy Dog
in the title case. We detect such cases.
It is very difficult to detect all non-title cases because of the many exceptions and styles. We highly recommend using Title Case Converter or Capitalize My Title to convert the title in your preferred style.
We test the string inside the {} is invariant by the function toTitleCase implemented based on to-title-case, JavaScript library. There might be some false positives and negatives.
APA Style.
Ref by WORDVICE.
LLUnRef
Detect \label{...} in figure and table environments that are never referenced by \ref{...} or \cref{...} in .tex files.
Reference all the figures and tables you label to ensure there are no unused labels in your document.
LLURL
Detect URLs containing query strings in .tex or .md files.
The following query strings are considered unnecessary:
- ?utm_... (see Wikipedia)
- ?sessionid=...
- ?user=...
- ?email=...
The other query strings are allowed:
- ?q=...
- ?page=...
- ?lang=...
LLUserDefined
You can define your own regular expressions to detect in .tex or .md files.
Check LaTex Lint: Add Custom Detection Rule for more details.
We listed some examples in the following.
Example 1: Use mathrm for English letters
When you use English letters in math mode for an explanation, you should use \mathrm.
For example, if the character a is not a variable and represents something like atractive force, f^a(x) should be written as f^{\mathrm{a}}(x).

However, it is difficult to detect without context. You can define the rule f\^a to detect this pattern.
Example 2: Use appropriately defined operators
When you use operators, you should use \DeclareMathOperator.
For example, if you use \Box as a infimal convolution, you should define it as an operator.
\DeclareMathOperator{\infConv}{\Box}

Then, you can use \infConv instead of \Box.
Other Features
You can also use the following features. These commands are available by clicking the icon on the editor toolbar.

LaTeX Lint: Add Custom Detection Rule
Add your own rule to detect.
For example, we can detect f^a by the following steps.
1. Select the string you want to detect (optional)

2. Run the command (Add Custom Detection Rule)
Run the commands by clicking the icon or opening the command palette (Ctrl+Shift+P) and type LaTeX Lint: Add Custom Detection Rule.

3. Follow the instructions
If you choose string, we detect the input itself.
If you choose Regex, we detect the pattern using Regex.
Then, you can define your own rule.
LaTeX Lint: Choose Detection Rules
Select which rules to detect. Check the rules you want to detect.

LaTeX Lint: Rename Command or Label
Rename by pressing F2 on the \begin{name}, \end{name} or \label{name}.

LaTeX Lint: Query Wolfram Alpha
Query Wolfram Alpha to solve the equation.
1. Select the equation you want to solve

2. Run the command (Query Wolfram Alpha)
Run the commands by clicking the icon or opening the command palette (Ctrl+Shift+P) and type LaTeX Lint: Query Wolfram Alpha.

3. Check the Wolfram Alpha page
You can see the result on the Wolfram Alpha page. We remove some unnecessary commands when sending the equation.

Note
As stated in the Rules, false positives and false negatives may occur. We apologize for the inconvenience. If you find any errors, please report them via GitHub Issues.
We always welcome any kind of feedback, suggestions, and pull requests!
When writing papers, please ensure you follow the style specified by the academic society or publisher.
We hope our extension will help you write papers.
Change Log
Refer to CHANGELOG.md.
License
We use MIT License.
(The library to-title-case is also under MIT License.)
Acknowledgement
In some aspects, our extension resembles
We sincerely appreciate the developers of these tools.