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}

Werner
  • 603,163
projetmbc
  • 13,315

2 Answers2

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

egreg
  • 1,121,712
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}

Werner
  • 603,163
  • 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 '23 at 19:43