4

I wanted to do something like this: How to have overlapping under-braces and over-braces

The example given is really great, so I tried it on my own: what I was hoping to achieve is to represent a contribution from four fields to Wick theorem by clipping pair of fields, so I tried this:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{mathtools}
\begin{document}
\begin{equation}
    \begin{aligned}
        \overbracket{\phi (x_1) \quad \phi (x_2)} \quad \overbracket{\phi (x_3) \quad \phi (x_4)} \\
        \rlap{$\overbracket{\phantom{\phi (x_1) \quad \phi(x_2) \quad \phi (x_3)}}$} \phi(x_1) \quad
        \underbracket{\phi (x_2) \quad \phi (x_3) \quad \phi (x_4)} \\
        \overbracket{\phi (x_1) \quad \underbracket{\phi (x_2) \quad \phi (x_3)} \quad \phi (x_5)}
    \end{aligned}
\end{equation}

\end{document}

enter image description here

Almost, but not quite! The under/overbrackets are starting and ending on the wrong position, I would rather stress the point (x_1, ...), where the bracket starts or ends. So I tried modifying it like this:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{mathtools}
\begin{document}

\begin{equation}
    \begin{aligned}
        \phi (x\!\!\overbracket{\,_{1}) \quad \phi (x\!}{\,}_{\!2}) \quad \phi (x\!\overbracket{_3) \quad \phi (x\!}{\,}_{\!4}) \\
        \rlap{$\phi (x\!\!\overbracket{\phantom{\,_1) \quad \phi(x_2) \quad \phi (x}}_3)$} \phi(x_1) \quad
        \phi (x\!\!\underbracket{\,_2) \quad \phi (x_3) \quad \phi (x\!}{\,}_{\!4}) \\
        \phi (x\!\!\overbracket{\,_1) \quad \phi (x\!\!\underbracket{\,_2) \quad \phi (x\!}{\,}_{\!3}) \quad \phi (x\!}{\,}_{\!4})
    \end{aligned}
\end{equation}

\end{document}

enter image description here

This is, in fact, very ugly code, but it works for the first and last case - because there are no interlapping clips. What is worse than ugly code, is that this is not working for the middle case (interlapping clip x1 - x3 and x2 - x4), when number 3 is positioned below the first overbracket (right under x_2, where the second clip starts), the right parenthesis is duplicated and also, if you watch carefully, the \phi (x is somewhat bold, so it's duplicated and slightly displaced too. How can I achieve the interlapping clips effect with exact positioning over x's without these issues?

Thank you.

P.S.: I'm using pdflatex in TeXworks

1
5

It's simpler to do it with pst-node: consider variables you want to link as \rnodes, and connect them with the \ncbar command:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{pst-node, auto-pst-pdf}

\begin{document}

\begin{postscript}
\begin{equation}
    \begin{gathered}
        \phi (\rnode{n1}{x_1}) \quad \phi (\rnode{n2}{x_2}) \quad\phi (\rnode{n3}{x_3}) \quad \phi (\rnode{n4}{x_4}) \\[1ex]
        \phi (\rnode{p1}{x_1}) \quad \phi(\rnode{p2}{x_2}) \quad \phi (\rnode{p3}{x_3}) \quad\phi(\rnode{p4}{x_4}) \\[2ex]
       \phi (\rnode{q1}{x_1}) \quad \phi (\rnode{q2}{x_2}) \quad \phi (\rnode{q3}{x_}3) \quad \phi (\rnode{q4}{x_4})
    \end{gathered}
\end{equation}
\psset{nodesep=3pt, arm=5pt, angle=90, linejoin=1}
\ncbar{n1}{n2}\ncbar{n3}{n4}
\ncbar{p1}{p3}\ncbar[nodesep=2pt, angle=-90]{p2}{p4}
\ncbar{q1}{q4}\ncbar[nodesep=2pt, angle=-90]{q2}{q3}
\end{postscript}

\end{document} 

enter image description here

9
  • This looks really good and it also possesses the same logic I was hoping for to achieve! if nobody come with something better in 12 hours (I doubt it), I'll accept this, ok? Thank you.
    – user16320
    May 26 '16 at 23:21
  • P.S.: after loading \usepackage{pst-node, auto-pst-pdf}, there is an error: ! Package auto-pst-pdf Error: "shell escape" (or "write18") is not enabled: auto-pst-pdf will not work! . See the auto-pst-pdf package documentation for explanation. Type H <return> for immediate help. ... l.134 Or turn off auto-pst-pdf.} % ? If I turn off auto-pst-pdf as suggested, the error occures with 'poscript' (latex doesnt recognize that).
    – user16320
    May 26 '16 at 23:56
  • Oh! yes. I forgot to mention it. To compile pstricks code with pdflatex, you have to launch it with the --enable-write18 switch (under MiKTeX) or -shell-escape (TeX Live, MacTeX). Alternatively, you can compile with XeLaTeX.
    – Bernard
    May 27 '16 at 0:22
  • I don't have "MiKTeX" in the 'typeset' menu...I can't find those things you described in my TeXworks...and XeLaTeX has a problem with some 'non utf8 characters', even I have imported [slovak]{babel}.
    – user16320
    May 27 '16 at 0:27
  • What is your distribution?
    – Bernard
    May 27 '16 at 0:33
4

Inspired by Bernard answer, just for exercise, below is solution based on TikZ picture:

\documentclass[tikz,
               border=3mm,
               preview
               ]{standalone}
\usetikzlibrary{matrix}

\begin{document}
    \begin{tikzpicture}
\matrix (m) [matrix of math nodes,inner ysep=0pt,row sep=2ex]
{
\phi(x_1)   &   \phi(x_2)   &   \phi(x_3)   &   \phi(x_4)   \\
\phi(x_1)   &   \phi(x_2)   &   \phi(x_3)   &   \phi(x_4)   \\
\phi(x_1)   &   \phi(x_2)   &   \phi(x_3)   &   \phi(x_4)   \\
};
\draw[thick,transform canvas={xshift=0.3ex}]
    (m-1-1) |- ([yshift=+1mm] m-1-2.north) -- (m-1-2)
    (m-1-3) |- ([yshift=+1mm] m-1-4.north) -- (m-1-4)
    (m-2-1) |- ([yshift=+1mm] m-2-3.north) -- (m-2-3)
    (m-2-2) |- ([yshift=-1mm] m-2-4.south) -- (m-2-4)
    (m-3-1) |- ([yshift=+1mm] m-3-4.north) -- (m-3-4)
    (m-3-2) |- ([yshift=-1mm] m-3-3.south) -- (m-3-3)
    ;
    \end{tikzpicture}
\end{document}

enter image description here

3
  • This is not much better. Notice the bolder phi in the second row. Also, subscript positioning doesn't match in the first and second row. Also phi's are not aligned at all.
    – user16320
    May 26 '16 at 23:59
  • In the firs version of my answer I try to show the way, how you can improve your code. However, result was unsatisfactory, so instead this, I rewrote answer with completely different approach. To my opinion with simple, concise and easy to understand code.
    – Zarko
    May 27 '16 at 0:44
  • Thank you, this is also great! However, I accepted the other solution because it is somewhat concise, plus the guy helped me with shell escape, so everything works now. Thank you anyway!
    – user16320
    May 27 '16 at 2:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.