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.

  • 1
    You can define a command like \newcommand\rp{) } and then do 1\rp first item. – Sergei Golovan Aug 27 '17 at 19:07
  • Can you provide an example with as document that has this delimiter issue? –  Aug 27 '17 at 19:07
  • Gave them use proper enumerate plus the enumitem package, then those ) are hidden inside refs – daleif Aug 27 '17 at 19:22
  • 1
    Then you can use something like \char41. – Sergei Golovan Aug 27 '17 at 19:26
  • @SergeiGolovan Yes, that is the answer. – Colin McLarty Aug 27 '17 at 19:28
  • 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? – ShreevatsaR Aug 27 '17 at 19:30
  • 2
    your example document produces no error so I do not understand this question at all. – David Carlisle Aug 27 '17 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. – David Carlisle Aug 27 '17 at 19:42
  • @DavidCarlisle Nothing is in error. Only one way of correctly inputting text worked poorly with my editor, and Sergei Golovan has given the alternative LaTeX input method I asked for, – Colin McLarty Aug 27 '17 at 19:48
  • \char41 is not standard latex syntax and makes assumptions that the font is using an encoding that has a ) in position 41 (which is probably true but ...) – David Carlisle Aug 27 '17 at 19:50
  • if for example you wanted to input the half-open interval [a,b) in math mode you should definitely not use the \char form. – David Carlisle Aug 27 '17 at 19:52
  • @DavidCarlisle Is there a better way to get LaTeX to produce a right paren without typing )? – Colin McLarty Aug 27 '17 at 19:55
  • well \symbol{41} is the correct latex version of \char41 but suffers from the same failings about assumptions of font encodings. It is just wrong to obfuscate your source code because of incorrect warnings from your editor, can you not use something like %(<newline>1) dog ? – David Carlisle Aug 27 '17 at 20:01
  • @DavidCarlisle I see what you mean about obfuscating code, but I do not know how you mean I should enter %(1) dog. – Colin McLarty Aug 27 '17 at 20:07
  • 1
    I mean just put %( on the line above 1) so that an editor that wants to match brackets sees a ( and a ) – David Carlisle Aug 27 '17 at 20:08
  • Asking out of curiosity: What editor is this, BTW, that is good enough to look for paired delimiters, but not smart enough to let you configure its behaviour? – ShreevatsaR Aug 27 '17 at 20:50
  • @ShreevatsaR Not smart enough to read my mind. Most unpaired parens are errors. I'm not going to tell my editor to ignore unpaired right parens. The easy way to let the editor know what I mean, on this issue, is in David Carlisle's comment. – Colin McLarty Aug 27 '17 at 21:39

2 Answers2

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}
David Carlisle
  • 757,742
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.

ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149