1

I have a text that looks like

 {attribute_1=1, ARRAY=[ { "x" : 180 , "y" : 175 , "z" : 176} , { "x" : 179 , "y" : 176 , "z" : 177} , { "x" : 178 , "y" : 177 , "z" : 178} , { "x" : 177 , "y" : 177 , "z" : 179} , { "x" : 176 , "y" : 176 , "z" : 180} , { "x" : 175 , "y" : 175 , "z" : 179} , { "x" : 174 , "y" : 174 , "z" : 180} , { "x" : 173 , "y" : 173 , "z" : 181} , { "x" : 174 , "y" : 172 , "z" : 182} , { "x" : 174 , "y" : 171 , "z" : 183} , { "x" : 173 , "y" : 170 , "z" : 183} , { "x" : 172 , "y" : 171 , "z" : 184} , { "x" : 171 , "y" : 171 , "z" : 183} , { "x" : 170 , "y" : 170 , "z" : 182} , { "x" : 169 , "y" : 169 , "z" : 181} , { "x" : 168 , "y" : 168 , "z" : 180} , { "x" : 167 , "y" : 167 , "z" : 179} , { "x" : 166 , "y" : 166 , "z" : 178} , { "x" : 165 , "y" : 165 , "z" : 177} , { "x" : 164 , "y" : 164 , "z" : 176} , { "x" : 163 , "y" : 163 , "z" : 175} , { "x" : 162 , "y" : 162 , "z" : 174} , { "x" : 161 , "y" : 161 , "z" : 173} , { "x" : 160 , "y" : 160 , "z" : 172} , { "x" : 159 , "y" : 159 , "z" : 171} , { "x" : 158 , "y" : 158 , "z" : 170} , { "x" : 157 , "y" : 157 , "z" : 169} , { "x" : 157 , "y" : 158 , "z" : 170}]}

It is automatically generated data that I need to insert into my tex document. I have already tried \seqsplit and {verbatim} macros but I still have not word wrapping in compiled document. My long string goes over the border of the page and I can't see a part of data.

{verbatim} does not affect it, \seqsplit{line} follows to compilation error because my line contains "{" and "}".

How I can resolve this issue without changing the format of generated data?

Bobyandbob
  • 4,899

1 Answers1

1

A trick is to delimit the string with a character that doesn't appear in it, here I chose |.

\documentclass{article}
\usepackage{lipsum} % for context

\makeatletter
\newcommand{\galumov}[1]{%
  \begin{quote}\raggedright\footnotesize
  \catcode`#1=2
  \catcode`\{=12
  \catcode`\}=12
  \catcode`\_=12
  \ttfamily
  \expandafter\@galumov\expandafter{\iffalse}\fi
}
\def\@galumov#1{\expandafter#1\end{quote}}
\makeatother

\begin{document}

\lipsum[3]
\galumov|{attribute_1=1, ARRAY=[
 { "x" : 180 , "y" : 175 , "z" : 176} ,
 { "x" : 179 , "y" : 176 , "z" : 177} ,
 { "x" : 178 , "y" : 177 , "z" : 178} ,
 { "x" : 177 , "y" : 177 , "z" : 179} ,
 { "x" : 176 , "y" : 176 , "z" : 180} ,
 { "x" : 175 , "y" : 175 , "z" : 179} ,
 { "x" : 174 , "y" : 174 , "z" : 180} ,
 { "x" : 173 , "y" : 173 , "z" : 181} ,
 { "x" : 174 , "y" : 172 , "z" : 182} ,
 { "x" : 174 , "y" : 171 , "z" : 183} ,
 { "x" : 173 , "y" : 170 , "z" : 183} ,
 { "x" : 172 , "y" : 171 , "z" : 184} ,
 { "x" : 171 , "y" : 171 , "z" : 183} ,
 { "x" : 170 , "y" : 170 , "z" : 182} ,
 { "x" : 169 , "y" : 169 , "z" : 181} ,
 { "x" : 168 , "y" : 168 , "z" : 180} ,
 { "x" : 167 , "y" : 167 , "z" : 179} ,
 { "x" : 166 , "y" : 166 , "z" : 178} ,
 { "x" : 165 , "y" : 165 , "z" : 177} ,
 { "x" : 164 , "y" : 164 , "z" : 176} ,
 { "x" : 163 , "y" : 163 , "z" : 175} ,
 { "x" : 162 , "y" : 162 , "z" : 174} ,
 { "x" : 161 , "y" : 161 , "z" : 173} ,
 { "x" : 160 , "y" : 160 , "z" : 172} ,
 { "x" : 159 , "y" : 159 , "z" : 171} ,
 { "x" : 158 , "y" : 158 , "z" : 170} ,
 { "x" : 157 , "y" : 157 , "z" : 169} ,
 { "x" : 157 , "y" : 158 , "z" : 170}]}|
\lipsum[3]

\end{document}

The string has been reformatted for readability, but not changed in any other way. In order to get better formatting, other tricks are needed.

enter image description here

egreg
  • 1,121,712