How can I make a pair of words stick together in line breaks? For example, "MS Access". I don't want a line break in the middle. But, I'd like to set this up once, not at every occurrence of that word pair.

edit: Check out Sveinung's answer for two possible problems - overfull line, and hyphenation. For sure, I don't want that.

  • 4
    You could define a command, say \newcommand{\msaccess}{MS~Access}, which you could than use in your text. If you decide not to secure that space you just change it inside the definition.
    – Ronny
    Commented Feb 23, 2013 at 21:37
  • @Ronny: What do you mean by "If you decide not to secure that space you just change it inside the definition."? Commented Feb 23, 2013 at 21:42
  • @Ronny means, that if you decide that you don't want to prevent the linebreak in this word pair, you can just change it in the commands definition. Commented Feb 23, 2013 at 21:44
  • Thanks Benedikt, that's what I meant. The main discipline (while writing) is to use the command \msaccess in every occurrence ;)
    – Ronny
    Commented Feb 23, 2013 at 21:45
  • 2
    Well, it's kind of meant more general. I use this approach for mathematical notations, that i might change during the process of writing. Then i only have to change the notation at one place, not via search and replace. That's why i use own commands a lot.
    – Ronny
    Commented Feb 23, 2013 at 21:48

3 Answers 3


The correct answer may be to put the two word in an \mbox{keep together}. Then you avoid hyphenation, but not overfull lines.

You may define a macro to help you save some time when writing:


The flip side is that macros eat spaces. Therefore, in you text, you have to write \MSaccess{} to avoid that a space following the macros disappears. You may try to load the package xspace, and define the command as:


Unfortunately, there are situations where xspace does not work, and it may be better to define the command using the TeX-command def:


Then, you can write \MSA/ (notice the slash), and LaTeX will not eat a following space. Unfortunately, such commands may be awkward to type keyboards other than US-English.

If you use small caps in your macro, be sure that the font you use has real small caps, and of course, small caps has to be letterspaced (see Bringhurst, The Elements of Typographic Style). Actually, also the MS should be letterspaced according to Bringhurst.

I agree with Anon in his answer: Typographically a line break between MS and Access looks better than a sloppy paragraph or an overfull line (a line sticking out in the right margin). Even worse

will be that `Ac-
cess` is hyphenated.

I suggest that you write your article, and when your are finished, as the last touch up when proof reading, you check the line breaks to see if you have places where there is a line break between MS and Access (or Access is hyphenated) and then put the words in an \mbox{MS Access}.

This MWE demonstrates some of the differences:


\newcommand{\MSaccess}{\textsc{MS}~Access} % NB! \textsc has no effect


Here is a text which only purpose is to demonstrate that
\MSaccess without \emph{xspace} eats spaces.

Here is the text which only purpose is to demonstrate the wonders 
\emph{xspace} does for \MSaccessx and that \emph{xspace} does not eat spaces. But look here 
«\MSaccessx», and how we get a space before the nice, French citation mark (NB! 
\emph{xspace} may be configured to avoid this).

And here is the eminent `def`-macro that does not eat any spaces, as I state,
\MSA/ is OK, and does not fail because of strange punctuation, «\MSA/».


enter image description here

  • Yes, those two cases that you mention - overfull line, and hyphenated - are even worse. With your two solutions, are they still possible? Also, what do you mean with macros eat spaces? I have the Abbrev minor mode in Emacs, and it appears it just inserts the more complicated command every time I type msa followed by space. Isn't that equivalent to just typing it literally? Commented Feb 24, 2013 at 11:07
  • I have updated my answer with a MWE and an explanation. \mboxavoids hyphenation, but not overfull lines. Using the editor's auto-completion facility (as you describe) is something else than defining LaTeX-macros.
    – Sveinung
    Commented Feb 24, 2013 at 16:11
  • 1
    +1 particularly for last minute tinkering: "... when your are finished, as the last thing you do when proof reading, is to check if you have some places where you have a line break between MS and Access and then put the words in an \mbox{MS Access}." Commented Feb 17, 2017 at 19:19

You do not need to define any macro.

Simply learn to type MS~Access. The tilde is TeX's syntax for preventing a break. (IIRC, how it works is that it creates a very high penalty for a break at that spot.)

The macro business in the other answers is a red herring. The tilde does the work, whether in a macro expansion or not.

  • 3
    I think this should be a comment rather than an answer. Moreover, for recurring instances of the same thing, it's advisable to define a macro. Why? Because tomorrow you might think it fancy to emphasize the fact that this is a product name by writing it \textsc{MS~Access}. And if your original usage is spread across different files, keeping things consistent would be problematic. As reference, see Consistent typography.
    – Werner
    Commented Feb 24, 2013 at 4:08
  • 1
    The word "the" recurs frequently. Do you have a macro for it? Anyway, macros for recurring instances has nothing to do with the topic of this question, which is how to get TeX not to break MS away from Access across a new line.
    – Anon
    Commented Mar 3, 2013 at 3:16

I don't know if there's a built-in mechanism like \hyphenation for this, but you could simply define own commands for such word groups, for example


which you then can use in the text.


Some random text \MSaccess{}, some more text...

should output

Some random text MS Access, some more text

where there is no line break allowed between MS and Access.

As user Sveinung pointed out in the comments, the above command will still allow hyphenation of the involved words, i.e. MS<linebreak>Access would be forbidden, but LaTeX could possibly hyphenate it toMS Ac-<linebreak>cess. This may be OK in some cases, especially when the words that should be kept together are rather long. If also hyphenation shall not be allowed, one can change the command from above to

\newcommand{\MSaccess}{\mbox{MS Access}}

which will then also prevent hyphenation.

  • Yes, but that will be a bit disruptive. I'm writing a paper on MS Access (don't laugh!) and I write that all the time. To pause, and actually write the command, will not be optimal. I guess I could do a search-and-replace last thing, but still, I'll hold my breath for a solution the way I had in mind. Commented Feb 23, 2013 at 21:44
  • 1
    What do you mean with "to pause"? You just have to enter an additional ´´``. And yes, I already thought about some ironic comment on writing about MS Access in LaTeX ;-) Commented Feb 23, 2013 at 21:47
  • I mean a mental pause, to write the command instead of just the way you would like any other words. But it is still a good suggestion, just not 100% the way I like it. Commented Feb 23, 2013 at 21:48
  • 1
    There is no need to define a special command. Simply write MS~Access. As Knuth explains in "Breaking Paragraphs into Lines", sometimes computers just need our help ;-) Commented Feb 23, 2013 at 22:12
  • 4
    Btw, maybe your editor can help you? You could define an abbreviation, say msa, to expand into MS~Access. Commented Feb 23, 2013 at 22:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .