Springer Nature – Problems with Springer Nature Template and Qtree

linguisticsqtreespringernaturevertical alignment

I have a problem regarding the package qtree in combination with the Springer Nature Template. Once I put my paper in this template, the trees appear in a weird shape: the nodes appear separated, the tree image overlaps with the text. Does anyone know the solution to this issue?

\documentclass[referee,sn-basic]{sn-jnl}

   \usepackage{graphicx}

\usepackage{stmaryrd}




 \usepackage{graphicx}




 \usepackage{qtree,tree-dvips}

 \usepackage{linguex}

\begin{document}

\ex. \Tree  [.A \qroof{something here}.DP [.B  C  ]]
\end{document}

`
tree image

In the documentation of qtree, it says:

Qtree will not work with journal style X Any number of things could be
going wrong, of course, but start by checking if the journal’s style
redefines the tabular environment. Qtree makes internal calls to
tabular, so this is a frequent source of problems. Usually the style’s
writer has saved the original definition of \tabular under a different
name, so all you need to do is arrange for the original definition to
be restored during the calls to \Tree. You can define \qtreeinithook
to carry out the necessary redefinitions. It is called at the
beginning of each call to \Tree, with local scope (so that any
redefinitions it makes are automatically canceled at the end of the
call to \Tree). For example, the JNLE style (nle.sty) saves the
standard commands to begin and end a table as \oldtabular and
\endoldtabular, respectively, and the replacement macros result in r e
a l l y w i d e trees.

The following will restore the original definitions for calls to \Tree only. \def\qtreeinithook{\let\tabular=\oldtabular
\let\endtabular=\endoldtabular}

However, I don't know how to find the commands in the style file of the journal to define the qtreeinithook.

Best Answer

There are two things going on here. As noted in the comments, the [referee] option of the class loads setspace and sets the spacing to \doublespacing. But the class also redefines \raggedright which results in extra space being inserted above node labels, because the qtree labels are created using the {flushleft} environment (which is defined as a list using \raggedright).

The class should absolutely not have clobbered the kernel definition of \raggedright but since it's almost impossible to get publishers to change their class files, here's a general solution which solves at least part of the underlying problem by fixing the {flushleft} environment itself. This will solve your glossing problem too, since the clgoss4e glossing macros that linguex uses also uses the {flushleft} environment. It will also solve any similar problems with any package that uses the {flushleft} environment.

With the restored definition of {flushleft} we only need to add \singlespacing to the \qtreeinithook macro to make sure that the rest of the tree is single spaced. I've also added some extra space after trees; you can remove this if you don't need it.

\documentclass[referee,sn-basic]{sn-jnl}
\usepackage{qtree}
\usepackage{linguex}
\usepackage{lipsum}
\providecommand{\singlespacing}{}
\makeatletter
% We first create a version of the kernel \raggedright command
\DeclareRobustCommand\oldrr{%
  \let\\\@centercr\@rightskip\@flushglue \rightskip\@rightskip
  \finalhyphendemerits=\z@
  \leftskip\z@skip
  \parindent\z@}
\makeatother
% Now redefine \flushleft to use the original version
\renewcommand\flushleft{\trivlist\oldrr\item\relax}
% Add \singlespacing to trees
\newcommand\qtreeinithook{\singlespacing}
% Add some extra space after the tree 
\newcommand\qtreefinalhook{\vspace{\baselineskip}}
\begin{document}
\lipsum[1]

\ex.\Tree  [.A \qroof{something here}.DP [.B  C  ]]


\lipsum[2]

\end{document}

output of code