3

I'm trying to create a tree structure using "xypic" package. Everything is ok except that when I write something inside

*modifier{text}

the default font used for labeling in xypic is not used. Instead the default font of the document is used. How to change this setting ?

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{lucidabr}
\usepackage{xypic}

\begin{document}

\xymatrix{
& Start \ar[dl] \ar[d] \ar[dr] & &\\
Font & is & different \ar[dl] \ar[d] \ar[dr]\\
& E \ar[dl] \ar[dr] & F & G\\
G \ar[dr] & & {}\save[]+<1.5cm,-0.7cm>*\txt<10pc>{%
This is a very long text here. How to change this ?} \restore\\
& I & &\\
}

\end{document}

enter image description here

1

1 Answer 1

1

Just tell LaTeX what font you want:

\documentclass{article}
\usepackage[all,cmtip]{xy}
\begin{document}
\xymatrix{
& \textit{Start} \ar[dl] \ar[d] \ar[dr] & &\\
\textit{Font} & \textit{is} & \textit{different} \ar[dl] \ar[d] \ar[dr]\\
& E \ar[dl] \ar[dr] & F & G\\
G \ar[dr] & & {}\save[]+<1.5cm,-0.7cm>*\txt<10pc>{%
\normalfont\sffamily
This is a very long text here. How to change this?} \restore\\
& I & &\\
}
\end{document}

I've used \sffamily, but it can be any set of font changing declarations. With \normalfont you ensure to be in the "initial state".

Note also \textit{...} around the textual entries in the nodes, to get the font right. Also there you can use something like

\textnormal{<font declarations>Start}

enter image description here

If you are using the Lucida fonts, then this might be what you want:

\documentclass{article}
\usepackage{lucimatx}
\usepackage[all,cmtip]{xy}
\newcommand{\xtextit}[1]{\textnormal{\itshape #1}}
\newcommand{\xitshape}{\normalfont\itshape}

\begin{document}
\xymatrix{
& \xtextit{Start} \ar[dl] \ar[d] \ar[dr] & &\\
\xtextit{Font} & \xtextit{is} & \xtextit{different} \ar[dl] \ar[d] \ar[dr]\\
& E \ar[dl] \ar[dr] & F & G\\
G \ar[dr] & & {}\save[]+<1.5cm,-0.7cm>*\txt<10pc>{%
\linespread{1.1}\xitshape
This is a very long text here. How to change this?} \restore\\
& I & &\\
}
\end{document}

The commands \xtextit and \xitshape are just to ensure that the chosen font is selected, independently of the context. Possibly \textit and \itshape are sufficient. The \linespread{1.1} can be unnecessary if you load scaled down Lucida fonts. (I don't have lucidabr.sty, which is old; I only own the last Type1 version of the Lucida fonts, which uses `lucimatx.sty.)

enter image description here

5
  • Thanks for the reply. I want the same font as used in the start of the tree. It is XYATIP- Medium and XYBTIP-Medium. Problem is I don't I don't know how to set these fonts
    – user30165
    May 4, 2013 at 12:58
  • xyatip and xybtip don't contain characters: they only have arrow tips.
    – egreg
    May 4, 2013 at 13:01
  • Now I got it. If you use Lucidabr package, the fonts doesn't match, in case of Computer Modern fonts, its the same. Just one more thing, which of the font you think it is as in the "Start" word ? LucidaBright-Italic (Type1) or LucidaNewMath-AltItalic (Type1)
    – user30165
    May 4, 2013 at 13:14
  • @RupsDell Can you add to your question a complete minimal example with the font packages you load?
    – egreg
    May 4, 2013 at 13:16
  • @RupsDell I don't have lucidabr, but with the more recent lucimatx I get the default math italic font for "Start" (which is not recommended, particularly in "different"). Better use \textnormal{\itshape Start} and saying something like \linespread{1.1}\normalfont\itshape when starting the content of \txt.
    – egreg
    May 4, 2013 at 13:38

You must log in to answer this question.