3

I am generating a LaTeX file, and I got some very long commands containing Windows path, which do not break at line end. For instance, I can have a line like this :

This is a \texttt{very\textbackslash{}long\textbackslash{}command\textbackslash{}that\textbackslash{}will\textbackslash{}not\textbackslash{}break\textbackslash{}at\textbackslash{}textbackslash{}the\textbackslash{}end\textbackslash{}of\textbackslash{}the\textbackslash{}line}.

Is there any way to set the \textbackslash{} (but the question would hold for any character) as a potential hyphenation point ? The generation is automated, so I cannot add a \- manually, which I would do normally.

  • I'm not sure I understand: \textbackslash is a macro. Do you actually mean the macro \textbackslash or rather \? – cgnieder Sep 22 '15 at 07:59
  • In this case it's a macro yes, but I am looking for a generic solution, for instance it would have been a Linux path, and in this case, I'd like the / to be an hyphenation point. So yes, in this case, I mean \textbackslash Sorry for being bad at explaining ^^ –  Sep 22 '15 at 08:01
  • Why don't you use the url package? – Ulrike Fischer Sep 22 '15 at 08:11
  • Because the above LaTeX code is generated via Pandoc, from an HTML source, so I have to work with that :) –  Sep 22 '15 at 08:13
  • Is the url correctly marked up in the html? – Ulrike Fischer Sep 22 '15 at 08:59
  • Perhaps this answer of egreg's might help: http://tex.stackexchange.com/questions/50777/how-to-emulate-url-hyphenating-without-using-the-url-package/50782#50782 – Steven B. Segletes Sep 22 '15 at 10:01

1 Answers1

1

If you are able to coerce the generating program to write, say, \bslash{} instead of \textbackslash, you can define

\newcommand{\bslash}{\textbackslash\penalty\exhyphenpenalty}

just like \slash is defined (which is the macro you can use for the similar problem with Unix paths).

egreg
  • 1,121,712