16

I m writing one article in which i need to write a paragraph full of medical terms. How can i wrap a text in a line without using line break (or hyphen)?

Regards

5
  • 8
    To prevent a word from breaking you may put it in a \mbox{....}. To avoid hyphens you may also use \usepackage{hyphenat} and use \nohyphens{<text>}. To make it global use \usepackage[none]{hyphenat}
    – user11232
    Commented Mar 1, 2013 at 2:23
  • 1
    Another technique is to typeset the paragraph in question in \raggedright mode. This may be preferable to maintaining full justification. The latter is likely to produce some lines with huge inter-word gaps when hyphenation is turned off.
    – Mico
    Commented Mar 1, 2013 at 3:17
  • 2
    This may or may not be what the OP is asking, but one question is how to line-break a word without the hyphen character, i.e. hyphenation without a hyphen. If this is not what the OP means, it might be useful to change the title from "wrap a word" to something like "wrap text" to prevent a misreading. Commented Mar 1, 2013 at 3:48
  • 2
    related question?
    – user10274
    Commented Mar 1, 2013 at 6:31
  • 1
    Maybe this is what you want: Wrapping long lines that contain no spaces. Commented Mar 1, 2013 at 11:54

3 Answers 3

9

You can break a word with no hyphen at the end of the line (see the other answers), but then it doesn't look like a broken word. It might be a good idea to use some other symbol there instead of the hyphen, for instance $\bm\cdot$ (with \usepackage{bm}). This can be done by defining:

\newcommand{\+}{\discretionary{\mbox{${\bm\cdot}\mkern-1mu$}}{}{}}

I strongly recommend using the package microtype too, which helps a lot here. I added a small negative \mkern after the dot, to make it protrude a bit to the right margin.

\documentclass{article}

\usepackage{bm}
\newcommand{\+}{\discretionary{\mbox{${\bm\cdot}\mkern-1mu$}}{}{}}
\usepackage{microtype}

\begin{document}

\hsize 4.75cm

x\hfill x

This is my\-very\-long\-word\-that\-I\-want\-to\-break\-at\-any\-of\-these\-given\-points

This is my\+very\+long\+word\+that\+I\+want\+to\+break\+at\+any\+of\+these\+given\+points

\renewcommand\+{\discretionary{}{}{}}

This is my\+very\+long\+word\+that\+I\+want\+to\+break\+at\+any\+of\+these\+given\+points

\end{document}
2
  • Is there any way to add spaces within text instead of using hyphen for line breaking.
    – manish
    Commented Mar 13, 2013 at 3:25
  • @user15662 Sorry, but I got completely lost and I don't understand what you want.
    – yo'
    Commented Mar 13, 2013 at 13:16
10

You can use

\usepackage{seqsplit}

and then use

\seqsplit{ATGTCCACTGATAAAAGTACACGCTATAATTTTCAGATTGAGAAAGCCCC
CTCGTTGGCGTACGCTGCAGGTCGAC}

this can be used for displaying DNA sequences, but probably does an alright job in your case as well

10

If you want to split a word but don't want a hyphen to be used where the split happens, you can define a new hyphenation style:

\def\+{\discretionary{}{}{}}

Now you can use it as in a\+very\+long\+word. However, this still requires to place this new non-hyphen manually.

From the TeXBook:

A discretionary break consists of three sequences of characters called the pre- break, post-break, and no-break texts. The idea is that if a line break occurs here, the pre-break text will appear at the end of the current line and the post-break text will occur at the beginning of the next line; but if no break occurs, the no-break text will appear in the current line. Users can specify discretionary breaks in complete generality by writing

\discretionary{⟨pre-break text⟩}{⟨post-break text⟩}{⟨no-break text⟩}

where the three texts consist entirely of characters, boxes, and kerns. For example, TEX can hyphenate the word ‘difficult’ between the f’s, even though this requires breaking the ‘ffi’ ligature into ‘f-’ followed by an ‘fi’ ligature, if the horizontal list contains di\discretionary{f-}{fi}{ffi}cult.

1
  • When using the babel package, the same effect (text breaking without hyphen) is accomplished with the notation "".
    – mpy
    Commented Mar 2, 2013 at 14:00

This site is temporarily in read-only mode and not accepting new answers.

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