1

I am trying to disable right justification of text in Latex because it leads to too many hyphens which turn out to be distracting.

I tried \raggedright as shown below.

\documentclass{article}
\usepackage{helvet}
\usepackage{tabularx}
\raggedright
\begin{document}
\section*{Foo}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras commodo
eleifend nisl, in finibus massa ullamcorper in. Integer a maximus nunc,
consequat porta lorem. Mauris bibendum blandit felis, in mollis dui
aliquet id. Donec non velit facilisis, maximus lorem a, hendrerit erat.
Donec sagittis nisl nec mauris aliquet, cursus sodales leo gravida. Duis
ac bibendum leo. Mauris scelerisque venenatis enim, in suscipit libero
mattis ac. Sed ac mi efficitur, sagittis risus vitae, rhoncus est. Nunc
nibh leo, bibendum sed massa ac, finibus pulvinar nibh. Sed a tempus
ligula. Integer vel auctor lacus, eu consectetur diam. 

\section*{Bar}
\begin{tabularx}{\linewidth}{l X}
RowA & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras
commodo eleifend nisl, in finibus massa ullamcorper in. Integer a
maximus nunc, consequat porta lorem. Mauris bibendum blandit felis, in
mollis. \\
RowB & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras
commodo eleifend nisl, in finibus massa ullamcorper in. Integer a
maximus nunc, consequat porta lorem. Mauris bibendum blandit felis, in
mollis. \\
\end{tabularx}
\end{document}

This leads to the following output.

enter image description here

You can see in the output that although right justification has been disabled in normal paragraphs, but right justification is still present inside the tabularx environment and hyphenation of words still occur there. How can I disable right justification in the complete document including the tabularx environment?

  • This is discussed on pages 392-394 of Knuth, Computers and Typesetting. Part of the problem is that \raggedright used \rightskip, but itemize uses \rightskip for something else.. – John Kormylo Jul 20 '15 at 15:57
3

You have to change the column with the package array. You could define a new column type for this:

% arara: pdflatex

\documentclass{article}
\usepackage{helvet}
\usepackage{tabularx}
\usepackage{array}
\raggedright
% if you find some solution like \renewcolumntpye{X}{...} it would be even nicer
\newcolumntype{R}{>{\raggedright\arraybackslash}X}

\begin{document}
    \section*{Foo}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras commodo
    eleifend nisl, in finibus massa ullamcorper in. Integer a maximus nunc,
    consequat porta lorem. Mauris bibendum blandit felis, in mollis dui
    aliquet id. Donec non velit facilisis, maximus lorem a, hendrerit erat.
    Donec sagittis nisl nec mauris aliquet, cursus sodales leo gravida. Duis
    ac bibendum leo. Mauris scelerisque venenatis enim, in suscipit libero
    mattis ac. Sed ac mi efficitur, sagittis risus vitae, rhoncus est. Nunc
    nibh leo, bibendum sed massa ac, finibus pulvinar nibh. Sed a tempus
    ligula. Integer vel auctor lacus, eu consectetur diam. 

    \section*{Bar}
    \begin{tabularx}{\linewidth}{l R}
        RowA & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras
        commodo eleifend nisl, in finibus massa ullamcorper in. Integer a
        maximus nunc, consequat porta lorem. Mauris bibendum blandit felis, in
        mollis. \\
        RowB & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras
        commodo eleifend nisl, in finibus massa ullamcorper in. Integer a
        maximus nunc, consequat porta lorem. Mauris bibendum blandit felis, in
        mollis. \\
    \end{tabularx}
\end{document}$

As a typographical compromise, I would recommend to use

\usepackage[<your language>]{babel}
\usepackage{ragged2e}
\usepackage{microtype}
\RaggedRight

instead of

\raggedright
| improve this answer | |
  • 1
    Redefining the X column type wouldn't be a great idea. – egreg Jul 20 '15 at 18:27
  • @egreg, ok, I was expecting that. :-) – LaRiFaRi Jul 20 '15 at 21:44

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.