1

I'm trying to stop line breaks at hyphens, e.g. for \lstinline{sudo yum install -y epel-release && sudo yum install -y scipy python-matplotlib git autoconf automake screen gcc-c++ rubber texlive-appendix}, I don't want epel-release nor python-matlib to be hyphenated.

I have the following attempt (thanks to https://tex.stackexchange.com/a/200498 and https://tex.stackexchange.com/a/119371):

\lstset{
  basicstyle=\ttfamily\lst@ifdisplaystyle\scriptsize\fi,
  columns=flexible,
  breaklines=true,  
  literate=-{\nobreak-\nobreak}3, % <--- 10K penalty to break around - (e.g. python-matplotlib)
}

This seems to work as expected, until a command comes along that has a double-hyphenated option, e.g. yum --disablerepo=*. That inserts a bunch of spaces randomly around the hyphens and looks horrible. I've added \raggedright to the basicstyle because I thought they might be justification, but that didn't help. Wrapping the whole paragraph with flushleft didn't either.

An example:

\documentclass{article}
\usepackage{listings}
\lstset{ % Set default for listings
  basicstyle=\ttfamily\lst@ifdisplaystyle\scriptsize\fi,
  columns=flexible,
  breaklines=true,  
  literate=-{\nobreak-\nobreak}3, % <--- 10K penalty to break around - (e.g. python-matplotlib) https://tex.stackexchange.com/a/200498 https://tex.stackexchange.com/a/119371
}

\begin{document}
Additional software installation: \lstinline`sudo yum install -y epel-release && sudo yum install -y scipy python-matplotlib git autoconf automake screen gcc-c++ rubber texlive-appendix`\\

Then build:\\
\lstinline`control build --build-opt1 --build-opt1-option optionA --build-opt1-option optionB --build-opt2 --build-opt2-option optionX --build-opt2-option optionY`
\end{document}
  • Make a complete example. Without it is is impossible to test solutions. – Ulrike Fischer Aug 07 '17 at 18:00
  • @UlrikeFischer Done. – Aaron D. Marasco Aug 07 '17 at 18:21
  • 3
    Why don't you use breakatwhitespace=true? You don't want break inside the options anyway. – Ulrike Fischer Aug 07 '17 at 19:06
  • @UlrikeFischer Because I'm a copypasta newb when it comes to LaTeX and didn't know about that option. ;) That definitely helps (along with removing the literate). If you post that as an answer and help me figure out how to get it to stop leaving overhanging text by moving the linebreak to the beginning of the too-long word, I'll accept it. – Aaron D. Marasco Aug 08 '17 at 10:59

0 Answers0