Math & ScienceDouble bracket spacing

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Captain Burek
Posts: 1
Joined: Wed May 31, 2023 11:38 am

Double bracket spacing

Post by Captain Burek »

I'm trying to write a macro to set interpretation brackets for semantics, i.e. double square brackets that are connected. The bracket height should adjust to the size of what's inside the brackets (since there can be complex formulae, tables, or trees). My problem is that the distance between the brackets seems to grow as their vertical size grows, so that either taller brackets don't connect any more (as in the MWE below), or, if I make the negative space wider, normal size brackets melt into one. So I need a way to automatically adjust the negative space between the opening and between the closing brackets according to the bracket height (or to turn the automatic width-to-height adjustment off).

Any help is appreciated.

Code: Select all

\newcommand{\interp}[2][w]{%
	\delimitershortfall5pt
	\ensuremath{\left[\hspace{-.3ex}\left[
		\mbox{#2}%
		\right]\hspace{-.3ex}
		\right]^#1}}

 \interp{This is how they're supposed to look} \interp{\Huge Foo} \interp{\rule{0mm}{20ex}\Huge Foo}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

Double bracket spacing

Post by rais »

Captain Burek wrote:(as in the MWE below)
[...]

Code: Select all

\newcommand{\interp}[2][w]{%
	\delimitershortfall5pt
	\ensuremath{\left[\hspace{-.3ex}\left[
		\mbox{#2}%
		\right]\hspace{-.3ex}
		\right]^#1}}

 \interp{This is how they're supposed to look} \interp{\Huge Foo} \interp{\rule{0mm}{20ex}\Huge Foo}
You seem to have misinterpreted, what an MWE really is. In short, a Infominimal working example is a piece of code that demonstrates your problem without the need of expanding/modifying said code by others.
Anyway, package stmaryrd provides variable-sized double-brackets:

Code: Select all

\documentclass{article}
\usepackage{stmaryrd}
\newcommand{\interp}[2][w]{%
	\delimitershortfall5pt
	\ensuremath{\left\llbracket
		\mbox{#2}%
		\right\rrbracket^#1}}

\begin{document}
 \interp{This is how they're supposed to look} \interp{\Huge Foo} \interp{\rule{0mm}{20ex}\Huge Foo}
 \end{document}
 
KR
Rainer
Post Reply