What is the chktex approved way of writing open intervals?
As the current maintainer of ChkTeX, I think @egreg's answer is great for many reasons, but you should also consider turning off those warnings. Not every warning in ChkTeX is meant to be useful in every situation, so there are several ways to suppress the warnings. They are (in order of increasing granularity):
- For all files, in
.chktexrc
- In each file in which it should be suppressed
% chktex-file #
- On each line where it should be suppressed
% chktex #
Where #
above stands for the error that you are trying to suppress.
See sections 6.1.3 and 6.1.4 of the manual which, in fact, uses half-open intervals as an example. :)
I don't think you can. Better, use an abstraction, so if you happen to need a change to the perverse notation ]a,b[
, you just change two characters in the code.
\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\interval}{sO{}mm}
{
\IfBooleanTF{#1}
{
\yannick_interval:NNnnn \left \right { } { #3 } { #4 }
}
{
\yannick_interval:NNnnn \mathopen \mathclose { #2 } { #3 } { #4 }
}
}
\cs_new_protected:Nn \yannick_interval:NNnnn
{
\str_case:nn { #4 }
{
{oo}{#1#3\c_yannick_left_open_tl #5 #2#3\c_yannick_right_open_tl}
{co}{#1#3[ #5 #2#3\c_yannick_right_open_tl}
{oc}{#1#3\c_yannick_left_open_tl #5 #2#3]}
{cc}{#1#3[ #5 #2#3]}
}
}
\tl_const:Nn \c_yannick_left_open_tl { ] } % non perverse: (
\tl_const:Nn \c_yannick_right_open_tl { [ } % non perverse: )
\ExplSyntaxOff
\begin{document}
$\interval{oo}{a,b}$
$\interval{co}{a,b}$
$\interval[\Big]{oc}{a,b}$
$\interval*{cc}{\dfrac{1}{2},3}$
\end{document}
After changing ]
into (
and [
into )
: