1

This question already has an answer here:

I am trying to fit a UML diagram in a page, but it overflowing to the right. I've tried hfill, flushright, flushleft but none of this work. Here is the code:

\documentclass[twoside,openright,titlepage,numbers=noenddot,headinclude,  footinclude=true,cleardoublepage=empty,abstractoff,BCOR=5mm,paper=a4,fontsize=11pt,ngerman,american]{scrreprt}
\usepackage{classicthesis}
\usepackage{tikz-uml}
\usetikzlibrary{positioning}

\begin{document}
See next page\clearpage
\begin{figure}[ht]
  \begin{tikzpicture}
    \umlclass{Accuracy}{}{}
    \umlclass[right=5mm of Accuracy]{DepParsing}{}{}
    \umlnest{DepParsing}{Accuracy}
    \umlclass[right=5mm of DepParsing]{LabeledSentence}{}{}
    \umlassoc{DepParsing}{LabeledSentence}
    \umlclass[right=5mm of LabeledSentence]{Tokens}{}{}
    \umlclass[above right=3cm and 2mm of LabeledSentence.north]{TrainSentence}{}{}
    \umlclass[above=5mm of LabeledSentence,left=5mm of TrainSentence]{TestSentence}{
      + words:Vector[Str]\\
      + tags:Vector[Str]\\
      + tree:Vector[Str]
    }{
      + size:Int
    }
    \umlVHVinherit{LabeledSentence}{TestSentence}
    \umlVHVinherit{LabeledSentence}{TrainSentence}
    \umlclass[x=0,y=0,left=5mm of TestSentence]{Node}{
      +lex:Str\\
      +pos:Int\\
      +posTag:Str\\
      +dep:Int\\
      +left:Vector[Node]\\
      +right:Vector[Node]
    }{}
    \umlassoc[mult=1..*,pos=0.5,recursive=-190|190|3cm]{Node}{Node}
    \umlassoc[mult2=1,mult1=*]{Node}{TestSentence}
    \umlassoc{LabeledSentence}{Tokens}
    \umlclass[below=5mm of DepParsing]{SVMAdapter}{}{}
    \umlassoc{SVMAdapter}{DepParsing}
    \umlclass[left=5mm of SVMAdapter]{SVMProblem}{}{}
    \umlnest{SVMAdapter}{SVMProblem}
  \end{tikzpicture}
\end{figure}
\end{document}

Here is the output:

s

What can I do?

NOTE: I am using ClassicThesis

Best regards

marked as duplicate by Torbjørn T. tikz-pgf Dec 7 '16 at 11:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You've forgot to add the positioning TikZ-library, but after adding that I don't get the result in your screenshot, the diagram is much further to the left, and within the page. It's still slightly wider than the textblock, so you get an overfull hbox warning, but not as bad as what you show. – Torbjørn T. Dec 7 '16 at 10:01
  • I've updated the code, also I've added the positioning ilb in my code. – ElBaulP Dec 7 '16 at 10:05
  • What version of tikz-uml.sty do you have? I have the one with “fixes made in March 2016”. – egreg Dec 7 '16 at 10:09
  • Your code still does not produce the output in your screenshot ... Are you using classicthesis or something? Anyway, the general solution to the problem of too wide diagrams is to make the diagram narrower, for example by restructuring it. If that's not an option you could try centering it around the textblock, using \makebox or adjustbox as discussed in tex.stackexchange.com/a/39436/586 – Torbjørn T. Dec 7 '16 at 10:09
  • 1
    Yes, didn't see your note before I wrote my comment. You also need the figure to be on an even page to reproduce the alignment in the screenshot, hence my edit. Did you try \makebox[\textwidth][c]{<insert tikzpicture here>} or the adjustbox environment, as in the link I posted? Is that what you wanted to do? – Torbjørn T. Dec 7 '16 at 10:32