1

I want "GAD65(+/--)" never to be broken in my entire document. When I put \mbox{GAD65(+/--)} it works, but I don´t want to edit each single "GAD65(+/--)". Can I set this for the entire document?

I wrote \mbox{GAD65(+/--)} into the .cls file, where the word breaking, orphans and so are defined, but it does´t work.

  • Welcome to TeX.SX! The best strategy is to have \newcommand{\GAD}{\mbox{GAD65(+/--)}} in the preamble and to use \GAD{} in the document body. – egreg May 16 '15 at 23:21
  • @egreg why the braces in the newcommand? You don't need them if there aren't arguments, right? – Alenanno May 17 '15 at 1:21
  • @Alenanno \newcommand{\GAD}{...} and \newcommand\GAD{...} are completely equivalent; the former is the syntax used in the manual. – egreg May 17 '15 at 9:15
  • @egreg I was referring to using \GAD{} in the document body. If the value is fixed you could just use \GAD... no? Maybe I'm missing something. :D – Alenanno May 17 '15 at 9:35
  • @Alenanno Oh! Those braces! Well, TeX would eat a space after \GAD, without them. – egreg May 17 '15 at 9:42
1

I'd define a command and use the \xspace command to take care of spaces following that command. In the example below I have added a variant for the second paragraph where I use \small for GAD65 because I believe it looks better to typeset acronyms a little smaller. I'm using \sloppy as the unbreakability of GAD65 leads otherwise to overfull lines.

\documentclass{article}
\usepackage{xspace}

\newcommand\GAD{\mbox{GAD65(+/--)}\xspace}

\begin{document}

\sloppy
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam \GAD
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam \GAD erat,
sed diam voluptua.  At vero eos et accusam et justo duo dolores et ea \GAD.
Stet clita kasd gubergren, no sea takimata sanctus \GAD est Lorem ipsum
dolor sit amet.  Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
erat, sed diam \GAD.  At vero eos et accusam et justo duo dolores et ea
rebum.  Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum
dolor sit amet.

\renewcommand\GAD{\mbox{\small GAD65(+/--)}\xspace}

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam \GAD
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam \GAD erat,
sed diam voluptua.  At vero eos et accusam et justo duo dolores et ea \GAD.
Stet clita kasd gubergren, no sea takimata sanctus \GAD est Lorem ipsum
dolor sit amet.  Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
erat, sed diam \GAD.  At vero eos et accusam et justo duo dolores et ea
rebum.  Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum
dolor sit amet.


\end{document}

enter image description here

|improve this answer|||||
  • 1
    Maybe GAD65($+$/$-$) would be slightly better, wouldn't it? – GuM May 17 '15 at 14:18
  • I agree that something like $\mathrm{GAD}\,65(+/-)$ should be better as it would take advantage of TeX's typography for math but the difference is actually pretty small. – Christian Lindig May 17 '15 at 15:15
  • Indeed, I said “slightly”… :-) – GuM May 17 '15 at 17:18

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.