Re: Problema TeXnico: parsing di righe

#55774
Up
0
Down
::


La soluzione più ovvia è usare argomenti delimitati, cosa che però richiede il linguaggio TeX di base:
`
\makeatletter
\def\threelines#1\\#2\\#3\\{%
\ifx\@empty#1\@empty % if #1 is empty
\else
{\bfseries #1}\\%
{\itshape #2}\\%
#3\\%
\expandafter\threelines
\fi
}
\makeatother
`
Usando una macro del genere, però, è facile andare “fuori sincrono”: sarebbe meglio marcare la fine di ogni gruppo di tre linee con una sequenza di controllo differente. Per esempio:
`
\makeatletter
\def\threelines#1\\#2\\#3\/{%
\ifx\@empty#1\@empty % if #1 is empty
\else
{\bfseries #1}\\%
{\itshape #2}\\%
#3\\%
\expandafter\threelines
\fi
}
\makeatother
`
da usarsi così:
`
\threelines
Linea 1\\
Linea 2\\
Linea 3\/
Linea 4\\
Linea 5\\
Linea 6\/
`
eccetera. Naturalmente questa è solo l’idea generale, poi i dettagli andrebbero raffinati. Per esempio, cosa fare se lo schema con cui si devono susseguire le linee non è rispettato, e cose del genere.

Ciao.


Gustavo

Go to top