I'm using Pandoc to generate LaTeX. My text contains inline code spans (backticks in markdown) that are rendered as \texttt{...} in TeX. However, some of them are quite long and overflow the line, for example this paragraph:
In the context of the variables
\texttt{\{"query": "mycelium", "number": 100\}}, this would be expanded to
the URI \texttt{http://www.example.com/foo?query=mycelium\&number=100}.
I cannot change the generated code since that would affect the output when rendering to HTML.
I tried to insert a unicode zero-width space, but pdflatex chokes on that. I cannot use TeX commands inside the verbatim environment since Pandoc escapes all those before outputting them inside a \texttt:
$ echo 'my `code\bar`' | pandoc -t latex
my \texttt{code\textbackslash{}bar}
So what I'm looking for is a TeX command that redefines \texttt to reflow the line when it's too long. Or alternatively, a command to break all words that are too long on special characters like ?=%&.
Edit: I tried the following but it doesn't have any effect (63 being the decimal ascii code point for ?):
\documentclass[]{article}
\usepackage{lmodern} % with or without this...
% ... either of the following don't work:
\DeclareFontFamily{T1}{cmtt}{\hyphenchar \font=63}
\DeclareTextFontCommand{\mytexttt}{\ttfamily\hyphenchar\font=63\relax}
\begin{document}
In the context of the variables
\texttt{\{"query": "mycelium", "number": 100\}}, this would be expanded to
the very long long long URI \texttt{http://www.example.com/foo?query=mycelium\&number=100}.
\end{document}
\url(packageurlorhyperref) instead of\textttfor URLs. – egreg Oct 23 '14 at 14:48fancyvrband also lets you specify your own TeX template (#14 at Pandoc - Demos, so I'm not sure why it's using\textttfor inline code anyway. – Mike Renfro Oct 23 '14 at 15:50fancyvrbonly for special situations, and templates don't affect the stuff that it puts where the$body$variable is. – mb21 Oct 23 '14 at 17:05hyperreffor those). I just want the\textttto wrap on lines. – mb21 Oct 23 '14 at 17:06\urlhas facilities for breaking at various points in the URI. – egreg Oct 23 '14 at 17:17\texttt(like e.g. JSON without spaces), not just urls. – mb21 Oct 24 '14 at 10:52urlpackage provides the\urlcommand which is just a version of verbatim allowing breaks. The corresponding command withhyperrefis\nolinkurl. – Andrew Swann Oct 25 '14 at 14:49