3

I was thinking of creating a figure similar to this: Lexem-Frame

On first glance, it looked quite doable through tikz

see MWE but when it comes to styles and refining the figure, I am a bit at a loss

  • having the tree grow down and to the right (for "Lesart"),
  • having different styles for the "bubbles" (Nomen, maus, Lesart) and "arrows" and arrows ending without bubble
  • having different spacing

/On a side note, is there also a way to change fonts for figures to make them more readable?

Would you mind to help here?

\documentclass[
  12pt,
  a4paper,
  headings=standardclasses,
  listof=totoc,
  numbers=noenddot
]{scrartcl}

\usepackage{showframe} \usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.00cm, footskip=1cm]{geometry} \usepackage[onehalfspacing]{setspace} \usepackage[main=ngerman, english]{babel} \usepackage[linguistics]{forest}

\usepackage{tikz} \usetikzlibrary{graphdrawing} \usetikzlibrary{graphs} \usegdlibrary{trees}

\begin{document} % \begin{figure} \begin{center} \begin{tikzpicture}[>=stealth, every node/.style={circle, draw, minimum size=0.75cm}] \graph [tree layout, grow=down, fresh nodes, level distance=1in, sibling distance=0.5in] { Nomen -> { Maus -> {Genus,Numerus,Register,Flex, Lesart 1 -> {" "," "," "}, Lesart 2 -> {" "," "," "}} } }; \end{tikzpicture} \end{center} \end{figure} \end{document}

MWE


Updated version that produces the unwanted configuration of arrows stemming from the same place:

    \documentclass[
  12pt,
  a4paper,
  headings=standardclasses,
  listof=totoc,
  numbers=noenddot
]{scrartcl}

\usepackage{showframe} \usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.00cm, footskip=1cm]{geometry} \usepackage[onehalfspacing]{setspace} \usepackage[main=ngerman, english]{babel} \usepackage[babel, german=quotes]{csquotes} \usepackage[ngerman]{isodate} \usepackage[ngerman]{datetime} %---------------------------------------------------------------------------- % FIGURES %---------------------------------------------------------------------------- %\usepackage{graphicx} %\graphicspath{ {./figures/} } %\usepackage{lscape} %\usepackage[final]{pdfpages} %\usepackage{chngcntr} \usepackage[linguistics]{forest} % linguistic figures \usepackage{tikz} \usetikzlibrary{arrows.meta,decorations.pathmorphing,backgrounds,fit,positioning,shapes.symbols,chains}

\forestset{ east branch/.style = {grow=east, child anchor=west, if level = 3{text width=2ex,draw=none,edge=dashed}{}} }% end of forestset

\begin{document} \begin{forest} for tree = { % node style circle, draw, text width = 4em, text badly centered, if level = 2{font=\sffamily\scshape\scriptsize\linespread{0.84}\selectfont} {font=\sffamily\itshape\scriptsize\linespread{0.84}\selectfont}, inner sep = 1pt, /tikz/every label/.append style = {align=left, font=\sffamily\scriptsize\linespread{0.84}\selectfont}, % tree style child anchor=north, edge = {-{Straight Barb[angle=60:2pt 3]}, semithick}, l sep=12mm, s sep=2mm, } % tree body code [Nomen, double, dashed, label=right: Versuh fuer einem \ Lexem-Frame fuer \textit{Mause}, [/maus/, double, [Genus [femin.]] [Numerus [sing.]] [Register/\ Silver [neutral]], [Flex.-Klasse [Sg. I. Pl. S1/U., label=right:Angabe der Flexionklasse hier\ nach \textsc{Duden-Grammmatic}\textsuperscript{7} 2005 ] ], [Lesart\ 1, for tree={east branch}, before computing xy={l=-9mm,s=35mm}, [] [] [] ] [test\ 2, for tree={east branch}, before computing xy={l=+9mm,s=35mm},
[] [] [] ] ] ] \end{forest} \end{document}

2 Answers2

7

One more solution with forest.

Edit (1): Slightly improved MWE code by introducing \forestset for settings of branches directed to east.

Edit (2): Added newtxtext packages that all fonts in nodes can be sffamily, corrected text in nodes.

Edit (3): Corrected positioning of text in nodes:

\documentclass[margin=3.141592mm]{standalone}
\usepackage{newtxtext}
\usepackage{forest}
\usetikzlibrary{arrows.meta}

\forestset{ east branch/.style = {grow=east, anchor=center, child anchor=west, if level = 3{text width=2ex,draw=none,edge=dashed}{}} }% end of forestset

\begin{document} \begin{forest} for tree = { % node style circle, draw, text width = 3.4em, text badly centered, inner sep = 1pt, anchor = center, if level = 2{font=\sffamily\scshape\scriptsize\linespread{0.84}\selectfont} {font=\sffamily\scriptsize\linespread{0.84}\selectfont}, if level = 3{font=\sffamily\itshape\scriptsize\linespread{0.84}\selectfont}{}, /tikz/every label/.append style = {align=left, font=\sffamily\scriptsize\linespread{0.84}\selectfont}, % tree style child anchor=north, edge = {-{Straight Barb[angle=60:2pt 3]}, semithick}, l sep=12mm, s sep=2mm, } % tree body code [Nomen, double, dashed, label=right: Versuh fuer einem \ Lexem-Frame fuer \textit{Mause}, [/maus/, double, [Genus [femin.]] [Numerus [sing.]] [Register/\ Silver [neutral]], [Flex.-Klasse [Sg. I. Pl. S1/U., label=right:Angabe der Flexionklasse hier\ nach \textsc{Duden-Grammmatic}\textsuperscript{7} 2005 ] ], [Lesart\ 1, for tree={east branch}, before computing xy={l=-9mm,s=35mm}, [] [] [] ] [Lesart\ 2, for tree={east branch}, before computing xy={l=+9mm,s=35mm},
[] [] [] ] ] ] \end{forest} \end{document}

enter image description here

Addednum: In case that some of yours forest diagram use the linguistics library, you can use it on the following way:

  • in preamble instead loading \usepackage[linguistics]{forest} load
    \usepackage{forest}
    \useforestlibrary{linguistics}
    
  • when you need to use a forest linguistics diagram, then insert \forestapplylibrarydefaults{linguistics} in local group, for example:
    \begingroup
    \forestapplylibrarydefaults{linguistics}
    \begin{forest}
    % forest specification
    % linguistics diagram code
    \end{forest}
    \end{group}
    

Please consider recent version of my forest code. It is more concise and has improved diagram layout.

Zarko
  • 296,517
4

Welcome to TeX.SX! Since you already load it, why don't you use the forest package:

\documentclass[
  12pt,
  a4paper,
]{scrartcl}

\usepackage[linguistics]{forest}

\begin{document} \begin{figure} \begin{center}

\forestset{ default preamble={ for tree={ circle, draw, font=\footnotesize, edge=->, l=25mm, } }, eastbound/.style={ edge path={\noexpand\path\forestoption{edge}--(.west)\forestoption{edge label};}, grow=east, ignore, }, }

\begin{forest} [Nomen, dashed [Maus [Genus] [Numerus] [Register] [Flex] [Lesart 1, before computing xy={l=15mm,s=35mm}, eastbound [{},draw=none][{},draw=none][{},draw=none]] [Lesart 2, before computing xy={l=-5mm,s=35mm}, eastbound [{},draw=none][{},draw=none][{},draw=none]] ] ] \end{forest}

\end{center} \end{figure}

\end{document}

enter image description here


Edit: You can simplify the edge path set-up and automatically process empty nodes:

\documentclass[
  12pt,
  a4paper,
]{scrartcl}

\usepackage[linguistics]{forest}

\begin{document} \begin{figure} \begin{center}

\forestset{ default preamble={ for tree={ circle, draw, font=\footnotesize, edge=->, edge path={\noexpand\path\forestoption{edge}--()\forestoption{edge label};}, l=25mm, }, delay={ where content={}{ draw=none, edge=dashed, }{}, } }, }

\begin{forest} [Nomen, dashed [Maus [Genus] [Numerus] [Register] [Flex] [Lesart 1, before computing xy={l=15mm,s=35mm}, grow=east, ignore [][][]] [Lesart 2, before computing xy={l=-5mm,s=35mm}, grow=east, ignore [][][]] ] ] \end{forest}

\end{center} \end{figure}

\end{document}

enter image description here


See also: Forest: different growing directions for branches on the same level