3

In a descriptive diagram, how do I prevent smart diagram from hyphenating texts when there are two more lines? Adding \raggedright does not work for me.

A minimal example

\documentclass{article}
\usepackage{smartdiagram}
\begin{document}
    \smartdiagramset{description title text width=1.5cm,
    description text width=7cm,description width=8cm}
    \smartdiagram[descriptive diagram]{
      {x,the contribution to the projection Xxxxxxxxx Xxxxx}}

\end{document}

Note that technically I can change the width to be really wide, but it's too troubling when there are too many long descriptions...

  • within the local group for the command, add \hyphenpenalty10000 \exhyphenpenalty10000. these are the settings to suppress hyphenation using the primitive attributes that govern hyphenation of ordinary words and words that already contain hyphens, respectively. when you exit the group, the values are automatically restored to the usual for the body text. – barbara beeton Apr 15 '16 at 0:58
  • The problem is that smardiagram uses align=center in the nodes, but doesn't seem to have any option for changing it to align=flush center (which would avoid hyphenation). – egreg Apr 15 '16 at 8:36
  • @egreg Interesting. Maybe we can ask whether the author is willing to add such an option? – xuhdev Apr 15 '16 at 18:33
4

the simplest method for suppressing hyphenation within a group is this:

within the local group for the command, add

\hyphenpenalty10000
\exhyphenpenalty10000

these are the settings to suppress hyphenation using the primitive attributes that govern hyphenation of ordinary words and words that already contain hyphens, respectively. when you exit the group, the values are automatically restored to the usual for the body text.

3

A quick workaround is to use command \mbox{not hyphenated}, because this command does not allow an hyphenation of included word(s).

Or you can use \\ to force a newline inside the description.

Or you can use command \hyphenation{...} to force that the listed word(s) is/are not hyphenated in the complete document. The word Donaudampfschifffahrt is a long german word I used to show the effect ...

Please see the following MWE (see marking <======):

\documentclass{article}
\hyphenation{Donaudampfschifffahrt}% <==================================
\usepackage{smartdiagram}
\begin{document}
\smartdiagramset{description title text width=1.5cm,
  description text width=7cm,description width=8cm}
\smartdiagram[descriptive diagram]{
  {x,the contribution to the \mbox{projection} Xxxxxxxxx Xxxxx}% <==============
}

\smartdiagram[descriptive diagram]{
  {x,the contribution to the projection\\ Xxxxxxxxx Xxxxx}% <==============
}

\smartdiagram[descriptive diagram]{
  {x,the contribution to the Donaudampfschifffahrt\\ Xxxxxxxxx Xxxxx}% <==============
}
\end{document}

and the result:

result of mwe above

  • Is it possible to automatically add mbox to all words? – xuhdev Apr 14 '16 at 23:41
  • I believe that a comma should replace your added % <==== – egreg Apr 15 '16 at 8:36
  • \smartdiagram[descriptive diagram]{{x,abc def},} You can, of course, use end-of-lines like in your answers, but the documentation advises to use a trailing comma. – egreg Apr 15 '16 at 15:35
  • @egreg Ah, I see. Well, I only added the % <=== to make my changing more visible, usually I would just write }}, but thanks for the hint. I got no error message, so I didn't look again into the documentation. – Kurt Apr 15 '16 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.