Although this is not a LaTeX problem and your editor/tool problem, this is the sort of thing you could make your editor smarter about: for example, you could use a heuristic like: A line indicates a numbered list if:
- it starts with a run of whitespace characters, a (small) sequence of digits, and a
)
, or in other words a regular expression like ^\s+[0-9]{1,2}\)
, and
- it either has more indentation than the previous non-empty line, or it has the same indentation as the previous non-empty line which itself indicates a numbered list.
Then you could write
\documentclass{article}
\begin{document}
1) Dog.
2) Cat.
\end{document}
and your heuristics would correctly ignore these )
s and not treat them as mismatched closing parentheses.
If you do want to write valid LaTeX code while “fooling” your editor into not making its dumb mistakes, then one trick is to use comments containing the “missing” (
s to match your )
s, as in David Carlisle's answer. You'd need one of these for every item in your list. Another trick is to use custom macros. For example, \(
is a macro defined in LaTeX, and optimistically intended as a replacement for $ ... $
(entering and exiting math mode), though I've not encountered anyone in the “wild” who uses them that way. If you use them for that purpose, good for you, I guess. If you don't, then \(
is available, to be redefined as a macro that does nothing:
\documentclass{article}
\renewcommand{\(}{}
\begin{document}
\(1) Dog.
\(2) Cat.
\end{document}
(Actually I would use \def\({}
here instead of \renewcommand{\(}{}
because the latter is equivalent to \long\def
which makes error-detection worse by allowing paragraph breaks, but \renewcommand
is preferred by LaTeX purists, but that's a digression.) (And if you wish you can define \)
as )
too, and write \(1\) Dog
instead.)
Of course the proper way would be to use an environment for the list, say using the enumerate package (read documentation: see author :)) as follows:
\documentclass{article}
\usepackage{enumerate}
\begin{document}
%( -- need this if your editor cannot be told to ignore parentheses inside the optional argument to enumerate
\begin{enumerate}[1)]
\item Dog.
\item Cat.
\end{enumerate}
\end{document}
This produces numbers like 1)
and 2)
in the output, though the typeset output of LaTeX isn't exactly easy to customize so if you need it to appear different you may find it hard to use.
\newcommand\rp{) }
and then do1\rp first item
.\char41
.