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}

See next page\clearpage
    \umlclass[right=5mm of Accuracy]{DepParsing}{}{}
    \umlclass[right=5mm of 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
    \umlclass[x=0,y=0,left=5mm of TestSentence]{Node}{
    \umlclass[below=5mm of DepParsing]{SVMAdapter}{}{}
    \umlclass[left=5mm of SVMAdapter]{SVMProblem}{}{}

Here is the output:


What can I do?

NOTE: I am using ClassicThesis

Best regards

  • 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