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.

  • Thank you for posting a working example! At the same time, much of your code does not seem to be relevant to the question you're asking here. Please limit the example to only the code required for your issue to appear. You can have a look at this guide for how to prune your code for this purpose. – Martin Schröder Jul 6 '18 at 12:46
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 3 '18 at 13:08

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.