0

Authors will sometimes number a list with numbers in the format 1) then 2) and so on. I sometimes have to quote these lists, and when I do of course they show up as delimiter errors. They do not block the file from compiling as I want, but they do interfere with my performing delimiter checks.

Is there a way to format 1) and 2) and so on, so that they will not appear as delimiters when I do delimiter checks?

Responding to a comment, here is an MWE. It gives a list with one entry, and the 1) appears as a delimiter error (as it should, of course).

\documentclass{article}
\begin{document}
1) Dog.
\end{document}

@ShreevatsaR Correctly says delimiter checks are an editor feature, not LaTeX. That is why I do not ask here about changing the delimiter check. I ask about LaTeX code.

17
  • 1
    You can define a command like \newcommand\rp{) } and then do 1\rp first item. Aug 27, 2017 at 19:07
  • 1
    Then you can use something like \char41. Aug 27, 2017 at 19:26
  • 3
    Where do you do the “delimiter checks”? Where do the “delimiter errors” appear? I think this is not a feature of (or question about) TeX/LaTeX, but of some editor or checking tool you use… what is it? Aug 27, 2017 at 19:30
  • 2
    your example document produces no error so I do not understand this question at all. Aug 27, 2017 at 19:38
  • 2
    It is not clear what you mean by "delimiter checks" but if these checks are giving warnings on correct input, then it is the checks that are in error not the document. Aug 27, 2017 at 19:42

2 Answers 2

3

The document is not in error. If your editor (erroneously) complains about mis-matched parens, you can probably do

\documentclass{article}
\begin{document}
%(
1) Dog.
\end{document}
0

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:

  1. 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
  2. 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.

1
  • You can use the starred version and write \renewcommand*{\(}{}
    – user94293
    Aug 28, 2017 at 1:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .