\documentclass{book} \newcommand{\intervalle}[4]{\mathopen{#1}#2\mathpunct{};#3\mathclose{#4}} \newcommand{\intervalleoo}[2]{\intervalle {\left. {\vphantom{\int_0^1}} % the problem comes from here... comment-uncomment \right]} {#1}{#2} {\left[ \right.}} \begin{document} Here it always works : $\intervalleoo{0}{2\pi}$ \subsection{Here it doesn't always work : $\intervalleoo{0}{2\pi}$} \end{document}
[SOLVED] : add
\protected\def\myphantom#1{\vphantom{#1}}