Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm writing some topology up, and I prefer to use the notation ]a,b[ to denote an open interval as opposed to (a,b), since the ( and ) symbols tend to be over used in this subject.

Is there a preferred practice for writing [ and ] as mathematical symbols as opposed to delimiters? While in my editor, I notice they are highlighted in red as unpaired delimiters. I also figure if ever want to go through and automatically change my notation of open interval, I would not want to change all [ and ] to ) and (, which would greatly mess things up.

share|improve this question
    
Similar question: How to input open intervals. –  Philippe Goutet Sep 1 '11 at 7:23
    
Minor comment on the editor matching: if you put \newcommand{\lb}{[}\newcommand{\rb}{]} (note the order!) early on and use \lb and \rb instead of [ and ] then the editor won't get confused. The order of the definitions should ensure that it doesn't think that there are any open groups. –  Loop Space Sep 1 '11 at 9:12
1  
minor quibble ... although the aspect of the brackets is reversed, when they indicate an open interval, they are still delimiters, not ordinary symbols. imperative distinction, otherwise the spacing can be compromised. –  barbara beeton Sep 1 '11 at 19:58
add comment

3 Answers 3

up vote 19 down vote accepted

It is advisable to define a command to handle such notation preferences. As you said, if you ever change your mind in the future, it would be a headache to make sure all your changes were incorporated.

Consequently, I would recommend something like (in LaTeX2e):

\newcommand{\ointerval}[1]{\ensuremath{\left]#1\right[}}% \ointerval{<interval>} -> ]#1[

and use

The open interval \ointerval{a,b} looks better than $(a,b)$.

In future, a change to \ointerval will spread throughout the document. For example, if you wanted to modify (say) the delimiters to ) (, this change will propagate on the next compile.

The choice of using extensible delimiters \left] and \right[ is highlighted by viewing it in comparison to other possible delimiters under different scenarios:

Delimiter choice

Your editor might still recognize unmatched brackets (] and [) since it is hardwired to math left to right, not right to left. However, it removes clutter from your editor view and improves flexibility.

share|improve this answer
    
Thanks Werner. I'll begin to incorporate this soon. –  yunone Aug 31 '11 at 18:33
10  
actually, \left] and \right[ will improve the spacing with respect to the interval argument, even if the vertical size isn't changed. alternatively, \mathopen{]} and \mathclose{[} (which don't adjust the height), although \left and \right take care of that automatically. (ref: texbook, p.155) –  barbara beeton Aug 31 '11 at 19:18
1  
Just to complement barbara's comment: See exercise 18.14 (page 171) and the discussion to its answer (page 322) of the TeXbook. –  Gonzalo Medina Aug 31 '11 at 19:32
1  
@Werner: you should really edit your answer to incorporate barbara's suggestion of using \mathopen{]} and \mathclose{[}. It's a shame to use a macro for an interval if it doesn't at least produce the right spacing (e.g. \ointerval{-1,1} will put too much space around the minus sign). –  Philippe Goutet Sep 1 '11 at 7:22
    
@Philippe: Thanks for highlighting a case that showed poor spacing. I've updated my answer with some motivation. –  Werner Sep 1 '11 at 7:51
add comment

The mathtools package offers an easy-to-use structure for such expressions.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{mathtools}   % loads »amsmath«

\DeclarePairedDelimiter{\oiv}{]}{[}

\begin{document}
  \[
    \oiv{a,b}
  \]
  \[
    \oiv*{\frac{a}{b},c}
  \]
\end{document}

For details refer to the package manual.

share|improve this answer
add comment

Here is a version that will automatically re-size the brackets depending on the parameters. So if you decide to switch notations this will just require changing this definition to use ) instead of ]. It also has the added benefit that it allows for changing the , separator to something else such as a : in the future if that is desired.

By default a small space gets added following the comma. But some prefer that this extra space not be added. If that is your preference, you can use the commented version of the the 2 parameter version which includes a curly braces around the comma {,} as per Mico's suggestion.

\documentclass{article}
\newcommand*{\Interval}[2]{\left]#1,#2\right[}%
%\newcommand*{\Interval}[2]{\left]#1{,}#2\right[}% Eliminate extra space following the ,
%\newcommand*{\Interval}[1]{\left]#1\right[}% Use this id you prefer using 1 parameter instead of 2


\begin{document}
\[
    \Interval{a}{b}
\]
\[
    \Interval{\frac{a}{b}}{c}
\]
\end{document}

enter image description here

share|improve this answer
    
Thanks Peter. Mind if I ask why you use \vphantom? I've never used those types of commands before. –  yunone Aug 31 '11 at 18:35
    
@Peter: The use of \vphantom here is not necessary, since the extensible \left and \right operators don't care about matching the brackets, just the respective \left and \right pairing. –  Werner Aug 31 '11 at 18:37
1  
this does the same! \left]\frac{a}{b},c\right[ –  Herbert Aug 31 '11 at 18:47
2  
and there is also no need for 2 parameters, one is enough –  Herbert Aug 31 '11 at 18:54
1  
@Mico, @Peter: the only context in which the comma shouldn't be followed by a small space in when you use it as a decimal separator (as in French). It's not a matter of personal preference but of readability (there's a reason why Knuth made \mathpunct atoms always have a small space after them). So you should not use {,} here. –  Philippe Goutet Sep 1 '11 at 7:15
show 16 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.