4

The following MWE shows a way to stretch left, "inside" and right delimiters. Is the use of \vphantom the good way to do that?

\documentclass{article}
\usepackage{amsmath}

\NewDocumentCommand\interlike{mm}{
  \left[ \vphantom{#2}#1 \right|\left.\vphantom{#1} #2 \right>
}

\begin{document}

$\interlike{\dfrac{X^X}{p_p}}{z}$

$\interlike{z}{\dfrac{X^X}{p_p}}$

\end{document}

2 Answers 2

5

I'd prefer the mathtools way.

\documentclass{article}
\usepackage{amsmath,mathtools}

\DeclarePairedDelimiterX{\interlike}[2]{\lbrack}{\rangle}{%
  #1 \,\delimsize|\, #2%
}

\begin{document}

\begin{gather*}
\interlike{a}{b} \\
\interlike[\big]{a}{b} \\
\interlike[\Big]{a}{b} \\
\interlike*{\frac{X^X}{p_p}}{z} \\
\interlike[\bigg]{z}{\frac{X^X}{p_p}}
\end{gather*}

\end{document}

See the documentation for \DeclarePairedDelimiterX for more details.

enter image description here

1
  • I was about to rebuild the Moon... :-)
    – projetmbc
    Aug 30 at 21:26
4

It works, but the spacing is off, and not because of the \vphantom. It's better to use \middle for this, which works with a \left...\right pair:

enter image description here

\documentclass{article}

\usepackage{amsmath}

\NewDocumentCommand{\interlike}{m m}{%
  \left[ \vphantom{#2}#1 \right|\left.\vphantom{#1} #2 \right]
}

\NewDocumentCommand{\newinterlike}{m m}{%
  \left[ #1 \middle| #2 \right]
}

\begin{document}

$\interlike{\dfrac{X^X}{p_p}}{z}$

$\newinterlike{\dfrac{X^X}{p_p}}{z}$

$\interlike{z}{\dfrac{X^X}{p_p}}$

$\newinterlike{z}{\dfrac{X^X}{p_p}}$

\end{document}
1
  • Thanks for pointing me to the middle of your proposition... :-) I had never seen this before... Good point also for the spacing issue.
    – projetmbc
    Aug 30 at 19:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .