Comments & Wishes\vphantom bug

General comments, feature, category or forum wishes for this LaTeX community
Post Reply
thomasb
Posts: 134
Joined: Thu Aug 03, 2017 10:54 am

\vphantom bug

Post by thomasb »

Here :

Code: Select all

\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

Code: Select all

\protected\def\myphantom#1{\vphantom{#1}}
Last edited by thomasb on Sat Aug 05, 2017 11:45 pm, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

\vphantom bug

Post by Stefan Kottwitz »

That's because \vphantom is a fragile command.

You could protect it from breaking:

Code: Select all

\protected\def\myphantom#1{\vphantom{#1}}

\newcommand{\intervalleoo}[2]{\intervalle
  {\left. 
      {\myphantom{\int_0^1}} % the problem comes from here... comment-uncomment
    \right]}
  {#1}{#2}
  {\left[ \right.}}
Stefan
LaTeX.org admin
Post Reply