0

I have a huge table (tabularx) which has a few columns which contain a lot of text. One of these columns contains long text but should not include a hyphen although it should break.

for example:

\documentclass[oneside,a4paper]{memoir}
\usepackage[english]{babel}
\RequirePackage{underscore}

\usepackage{blindtext}

%% Table Style
\RequirePackage{ltablex}
\RequirePackage{tabu}

\begin{document}

\begin{center}
\begin{tabularx}{\textwidth}{ |X|X|}
\hline
Function signature & Description \\ 
\hline
\hline
sdsadasdasdasdasdasd_dsfad_asdfasd_dsfad_asdfasd_dsfad_asdfasd()  & \blindtext \\ 
 \hline
asdasdasdasd_dsfad_asdfasd_dsfad_asdfasd_dsfad()  & \blindtext \\ 
 \hline
asdasdasdasd_dsfad_asdfasd_dsfad_asdfasd_dsfad() *StatsReport & \blindtext \\ 
 \hline
asdasdasdasd_dsfad_asdfasd_dsfad_asdfasd_dsfad()  & \blindtext \\ 
\hline
\end{tabularx}
\end{center}

\end{document}

In this case the first column should not contain hyphen although being split, as this will cause confusion.

Is there anyway to do that?

I tried all the tricks in this post but nothing worked.

Liron Levy
  • 29
  • 5

1 Answers1

1

The underscore package has a nohyphen option to suppress hyphens when text is broken at a underscore:

\usepackage[nohyphen]{underscore}

This fixes your example. To stop TeX from hyphenating the remaining text, you can add \hyphenchar\font=-1 at the beginning of the affected cells. The alternative would be to allow breaking words in other places too, but this is not necessary in your example and I would not recommend it because it looks confusing.

\documentclass[oneside,a4paper]{memoir}
\usepackage[english]{babel}
\RequirePackage[nohyphen]{underscore}

\usepackage{blindtext}

%% Table Style
\RequirePackage{ltablex}
\RequirePackage{tabu}
\begin{document}

\begin{center}
\begin{tabularx}{\textwidth}{ |X|X|}
\hline
Function signature & Description \\ 
\hline
\hline
\hyphenchar\font=-1 sdsadasdasdasdasdasd_dsfad_asdfasd_dsfad_asdfasd_dsfad_asdfasd()  & \blindtext \\ 
 \hline
\hyphenchar\font=-1 asdasdasdasd_dsfad_asdfasd_dsfad_asdfasd_dsfad()  & \blindtext \\ 
 \hline
\hyphenchar\font=-1 asdasdasdasd_dsfad_asdfasd_dsfad_asdfasd_dsfad() *StatsReport & \blindtext \\ 
 \hline
\hyphenchar\font=-1 asdasdasdasd_dsfad_asdfasd_dsfad_asdfasd_dsfad()  & \blindtext \\ 
\hline
\end{tabularx}
\end{center}

\end{document}

enter image description here

  • You are my hero... I tried both options before but apparently used them in the wrong places.

    Working great thanks.

    – Liron Levy Jul 03 '18 at 13:08