1

I'd like to document example requests/replies in our protocol per How to write narrative documentation. We're using the texlive-latex-base on Ubuntu for our documentation, and I'm linting with lacheck and chktex - I've managed to fix all warnings.

From questions such as this one I've managed to get runs of hex in my paragraphs flowing well, with the seqsplit package (might have to accept an extra dependency for it).

I need to document JSON with 32 byte hex encoded values. I've tried wrapping \verb|| with \seqsplit{} and with \begin{lstlisting}...\end{lstlisting} without success. I've tried putting \verb only around the { "key": " and " } parts, and using \texttt and \seqsplit on the inner part without success - the line still merrily flows right off the page. Ah, these are in a \begin{tabular}{l l}...\end{tabular} in \items of a \begin{description}...\end{description} block if relevant.

How can I get these \verbatim long lines to wrap? The common answer appears to be \lstlisting, but it has not worked for me, and additionally causes the linter to complain about "s from the JSON.

Example:

\documentclass{article}
\usepackage{seqsplit}
\newcommand{\hex}[1]{\texttt{0x#1}}

\begin{document}
\section{Examples}

Long 1: \hex{\seqsplit{d3c67ea2cafd4b3490a6dd0c61c1c3255be4ce2347aa0b123ef95acf4d89085a}}. Long 2: \hex{\seqsplit{9187043bcace4747eccf865281848e871724ac944631e95ccb4afa87c2a42774}}.\\

\begin{description}
    \item [From $\rightarrow$ To] Get long string $\rightarrow$ \texttt{\seqsplit{9187043bcace4747eccf865281848e871724ac944631e95ccb4afa87c2a42774}}
    \item [From $\rightarrow$ To] \begin{tabular}{l l}
        \texttt{POST} & \texttt{/api/endpoint} \\
        Request & \verb|{ "long1": "9187043bcace4747eccf865281848e871724ac944631e95ccb4afa87c2a42774" }| \\
        Response & \verb|{ "long2": "cd18978a5da7a0f7673e9185e8018aff3de003bbc4f3cfd133be27466173f66d" }| \\
    \end{tabular}
\end{description}

\end{document}
1

One of my prior attempts succeeded once I realized it was in a \begin{tabular}{l l}...\end{tabular} - particularly the l in tabular prevents wrapping. \seqsplit worked once I changed the second tabular l to p{9cm} and the innermost lines to:

        Request & \verb|{ "long1": "|\texttt{\seqsplit{9187043bcace4747eccf865281848e871724ac944631e95ccb4afa87c2a42774}}\verb|" }| \\
        Response & \verb|{ "long2": "|\texttt{\seqsplit{cd18978a5da7a0f7673e9185e8018aff3de003bbc4f3cfd133be27466173f66d}}\verb|" }| \\

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.