# How to align an equation horizontally in qtree, centering one character of my equation?

I have the following code for my qtree:

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}

\makeatletter
\usepackage{qtree}

\makeatother

\usepackage{babel}
\begin{document}
\Tree [.$\neg\left(\varphi\sqcup\psi\right)\circ \neg\varphi\sqcup\psi$
[.$\circ \left(\varphi \sqcup \psi \right)$ {$\varphi, \psi \circ$}
{$\circ \varphi,\psi$} ] ]
\hfill
\textbf{(8.2.1)}
\end{document}


I'm trying to center around the \circ character, so that the line in my tree starts at the \circ in my equation $\neg\left(\varphi\sqcup\psi\right)\circ \neg\varphi\sqcup\psi$, and ends at the \circ in $\circ \left(\varphi \sqcup \psi \right)$. I've tried \hspace{} but setting the right values to get the equations aligned correctly is horribly tedious.

I want to do either of the following two things:

Simply adjust the lining in my qtree so that they do not started centered, but instead at the \circ.

Or the more preferred method: compensate for the normal way of drawing lines by aligning my equation horizontally.

Does LaTeX or qtree offer a command to automatically align horizontally around one such character in my equation?

• Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – jub0bs Jan 14 '14 at 15:46

In this approach, I lapped all the components except the \circ, so that the tree would center on that symbol. I used an \hfill on both left and right so as to center the \circ horizontally on the line.

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{qtree}
\usepackage{lipsum}
\parskip 1ex
\begin{document}
\lipsum[1]

\hfill\Tree [.$\llap{$\neg\left(\varphi\sqcup\psi\right)$}\circ \rlap{$\neg\varphi\sqcup\psi$}$
[.$\circ \rlap{$\left(\varphi \sqcup \psi \right)$}$ {$\llap{$\varphi, \psi$} \circ$}
{$\circ\rlap{$\varphi,\psi$}$} ] ]
\hfill
\textbf{(8.2.1)}

\lipsum[2]
\end{document}


One can quickly and easily automate the process by creating a macro

\newcommand\ccen[2]{\llap{$#1$}$\circ$\rlap{$#2$}}


that is provided the contents to the left and right of the \circ. Its usage would be as follows:

\hfill\Tree [.\ccen{\neg\left(\varphi\sqcup\psi\right)}{\neg\varphi\sqcup\psi}
[.\ccen{}{\left(\varphi \sqcup \psi \right)} {\ccen{\varphi, \psi}{}}
{\ccen{}{\varphi,\psi}} ] ]
\hfill
\textbf{(8.2.1)}


If one would like space around the \circ, then this definition would do:

\newcommand\ccen[2]{\llap{$#1$}${}\mathrel{\circ}{}$\rlap{$#2$}}


which would produce this result:

• Yep, pretty much like this, though I'm trying to avoid the \hspace because I have to enter thousands of these formulas and I'd like a standardized method to implement this visual style. – 1010011010 Jan 14 '14 at 16:31
• @Euryris If you changed my \hspace*{4ex} to \hfill, then the trees will all be centered. Is that OK? – Steven B. Segletes Jan 14 '14 at 16:37
• Will this solution produce the same results regardless of how long/big the tree is? If so, then that'll suffice. Thank you. EDIT: Sorry, checked it. Yep, this seems to be exactly the solution I was looking for. – 1010011010 Jan 14 '14 at 17:06
• @Euryris I do not work with tree's to know the answer to your question. But even I can see that there could very easily be problems with more depth to the tree (since the lapping takes up zero horizontal space). – Steven B. Segletes Jan 14 '14 at 17:09