The basic problem here has more to do with how to center a linguex
example than how to center the tree, so it is actually asking essentially the same thing as gb4e center example text, but for linguex
instead of gb4e
. The solutions end up being the same:
- Use
\hfil
before and after the tikzpicture
environment, as suggested by Harish Kumar's comment on the question linked above.
- Use
\hspace*{\fill}
before and after the tikzpicture
environment, as suggested by egreg's comment to this answer.
- Use
\hfill
before and after the tikzpicture
environment, as suggested by Peter Grill's answer to the question linked above. You just have to make sure there is something with zero width at the end of the example (I used \hspace{0pt}
below, but you could use \null
as Peter Grill did); otherwise, the tree will be right-aligned instead of centered.
These yield the following output:
\documentclass[12pt,a4paper]{article}
\usepackage{tikz-qtree}
\usepackage{tikz-qtree-compat}
\usepackage{linguex}
\usepackage{showframe} % this just shows where the margins are -- comment out for the final version
\usepackage{lipsum} % for dummy text
\begin{document}
\ex. \lipsum[121]
\ex. \hfil
\begin{tikzpicture}[baseline] % baseline makes the example number stay at the top of the tree
\Tree [.VP [.V saw ] [.DP [.N Kim ] ] ]
\end{tikzpicture}%
\hfil
\ex. \hspace*{\fill}
\begin{tikzpicture}[baseline] % baseline makes the example number stay at the top of the tree
\Tree [.VP [.V saw ] [.DP [.N Kim ] ] ]
\end{tikzpicture}%
\hspace*{\fill}
\ex. \hfill
\begin{tikzpicture}[baseline] % baseline makes the example number stay at the top of the tree
\Tree [.VP [.V saw ] [.DP [.N Kim ] ] ]
\end{tikzpicture}%
\hfill\hspace{0pt} % without \hspace{0pt}, the tree would be right-aligned
\ex. \lipsum[130]
\end{document}
\usepackage{linguex}
. The same was true of the question you asked yesterday. Please edit the question to fix this, and try to make sure the MWE compiles as it is before submitting the question.