# Wordwrap text in small caps \textsc

I have several terms in small caps which include the character "/" such as:

\textsc{solarium/disapproved}

They are a part of regular text but sometimes when they appear at the end of the line, they end up going further than the margins (just that one line containing small caps peaks out). I would like the line to break when the text reaches the margin so that the line breaks mid-word as it would with a regular text which is not in small caps.

It is for a very long document (document class report) consisting of several chapters so I wouldn't want to change the settings for the whole document but only to manage those few lines.

The problem is that a combination of two words with a cat-12 token such as / (and not a space) separating them turns off the hyphenation algorithm when the / is reached, and does not reset it until a subsequent space is reached. The effect is that, not only does the / not permit line breaking, but the 2nd word becomes unhyphenate-able.

The introduction of the newly defined \z (call it anything you want) does two things...it allows a break after the / and with the introduction of \hspace{0pt}, it resets the hyphenation algorithm.

With that defined, I give three approaches to utilize it.

1. The default behavior, does not break at /, does not hyphenate afterwards.

2. Explicitly use /\z.

3. Use \bslash, which has been defined as /\z.

4. Turn on active / with \breakableslashon, in which case / in the middle of a word will automatically use this approach. However, this could break other applications of the / token, and so \breakableslashoff is provided to turn off the feature.

Of course, the most manual approach, not shown, is to literally type /\allowbreak\hspace{0pt} in your document itself. This is fine for a single irksome instance or two, but would become onerous with too many instances.

The MWE:

\documentclass{article}
\textwidth=0pt
\newcommand\z{\allowbreak\hspace{0pt}}
\catcode/=\active
\newcommand/{\char/\z}
\catcode/=12
\newcommand\bslash{/\z}
\newcommand\breakableslashon{\catcode/=\active }
\newcommand\breakableslashoff{\catcode/=12 }

\begin{document}
0. \textsc{solarium/disapproved}

1. \textsc{solarium/\z disapproved}

2. \textsc{solarium\bslash disapproved}

3. \breakableslashon
blah blah \textsc{solarium/disapproved} blah blah
\breakableslashoff
\end{document}


• For this option that is not shown with example (since I only have several instances of this term) I wrote: blahblahblah \textsc{solarium/\allowbreak\hspace{0pt}disapproved} blah. And it worked for breaking the line. Another question - This option that I mention in this comment cannot in any way affect the rest of my document, it will only affect this sentence? I wouldn't want to have to carefully check the other 250 pages of my document to see if something changed. – Leila May 4 at 13:55
• @Leila Correct. If you want a local change only for that particular instance (and you only have a few isolated instances), the manual approach of \textsc{solarium/\allowbreak\hspace{0pt}disapproved} is the safest, as it only affects the particular instance where it appears. – Steven B. Segletes May 4 at 14:06
• Also, if this is a special notation for something, then define a command for it, and you will do these things only once. Like \newcommand\frotz[2]{\textsc{#1\bslash #2}} and then \frotz{solarium}{disapproved}. – pst May 4 at 14:12

A slash where a line break is desirable happens quite often in TUGboat. Here's the code used there (it's defined in the class file, where the at modification isn't needed):

\makeatletter
\def\slash{/\penalty\z@\hskip\z@skip }
\makeatother


It would also probably be a good idea to change \def to \newcommand -- that will notify you if \slash` is already defined. (If it is, check the definition; it may already be what you need. Otherwise, you'd need another name.)