[NTG-context] Typesetting poetry with particular indenting
Tommaso Gordini
illinguista1972 at gmail.com
Thu Jul 2 17:33:43 CEST 2020
I have found this, that works, buy I don't know if there's a possibility of
using less code:
% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = ConTeXt-MkIV
% questo codice centra il blocco dei versi sulla pagina
\defineframedtext
[poemframed]
[width=\textwidth,
autowidth=force,
align=flushleft,
before=,
after=,
frame=off]
\definenarrower[poemnarrower]
\definelines
[poemlines]
[before={\startpoemnarrower[left]},
after=\stoppoemnarrower]
\definebuffer[poem]
\def\stoppoem{\setups{poems:buffer}}
\startsetups poems:buffer
\setupnarrower[poemnarrower][left=0pt]
\setbox\scratchbox\vbox
{\poemframed
{\startpoemlines
\getpoem
\stoppoemlines}}
\edef\poemhsize{\the\dimexpr(\hsize-\wd\scratchbox)/2\relax}
\setupnarrower[poemnarrower][left=\poemhsize]
\startpoemlines
\getpoem
\stoppoemlines
\stopsetups
% questo codice rientra ogni secondo e terzo verso
\unprotect
\installindentingmethod {three} {\c_spac_indentation_toggle_state\plusthree}
\unexpanded\def\spac_indentation_tri_toggle_indeed
{\glet\checkindentation\spac_indentation_tri_toggle}
\unexpanded\def\spac_indentation_tri_toggle
{\gdef\checkindentation
{\spac_indentation_remove
\gdef\checkindentation{\spac_indentation_tri_toggle_indeed}}}
% this next macro is redefinition of a core macro!
\def\spac_indentation_check_toggle
{\ifcase\c_spac_indentation_toggle_state
% nothing
\or
\spac_indentation_no_toggle
\or
\spac_indentation_do_toggle
\or
\spac_indentation_tri_toggle
\fi}
\protect
% questo codice attiva il rientro
\setupindenting[yes,1em]
\setuplines[indenting=three]
\starttext
\startpoem
Per correr miglior acque alza le vele
omai la navicella del mio ingegno,
che lascia dietro a sé mar sì crudele;
e canterò di quel secondo regno
dove l'umano spirito si purga
e di salire al ciel diventa degno.
Ma qui la morta poesì resurga,
o sante Muse, poi che vostro sono;
e qui Calïopè alquanto surga,
seguitando il mio canto con quel suono
di cui le Piche misere sentiro
lo colpo tal, che disperar perdono.
\stoppoem
\stoptext
Il giorno gio 2 lug 2020 alle ore 17:14 Tommaso Gordini <
illinguista1972 at gmail.com> ha scritto:
> Thanks, Wolfgang. Your example works, but the verse indentation (
> \setuplines[indenting=three]) is lost.
> There's a way to preserve it?
>
> Tommy
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20200702/b6890e60/attachment-0001.htm>
More information about the ntg-context
mailing list