Thanks to the edit in @Aditya's answer; finally I have an example that visualizes lipsum paragraphs in two column mode. I've simply used \let\processword\uline
to have the words underlined instead of boxed. The below example also simultaneously activates \showmakeup
:
\documentclass[twocolumn]{article}
\usepackage[nopar]{lipsum} % MUST be nopar!
\usepackage[normalem]{ulem} % for \uline underline
% https://tex.stackexchange.com/questions/26806/expanding-edef-a-lipsum-command
\makeatletter
\def\unpacklipsum#1#2#3{%
\count@=#1\relax
\advance\count@\m@ne
\def#3{}%
\loop\ifnum\count@<#2\relax
\advance\count@\@ne
\edef#3{#3\csname lipsum@\romannumeral\count@\endcsname}%
\repeat}
\makeatother
\makeatletter
% from syst-ext.mkii
\long\def\ConvertToConstant#1#2#3%
{\edef\@@stringa{\expandafter\detokenize\expandafter{#2}}%
\edef\@@stringb{\expandafter\detokenize\expandafter{#3}}%
#1{\@@stringa}{\@@stringb}}
% from core-fnt.mkii
\def\doprocesswords#1 #2\od
{\ConvertToConstant\doifnot{#1}{}
{\processword{#1} %
% expandafter added
\expandafter\doprocesswords#2 \od}}
% from core-fnt.mkii
\def\processwords#1%
{\doprocesswords#1 \od\unskip}
% from syst-gen.mkii
\long\def\doifnot#1#2%
{\let\donottest\dontprocesstest
\edef\@@stringa{#1}%
\edef\@@stringb{#2}%
\let\donottest\doprocesstest
\ifx\@@stringa\@@stringb
\expandafter\gobbleoneargument
\else
\expandafter\firstofoneargument
\fi}
\long\def\gobbleoneargument#1{}
\long\def\firstofoneargument#1{#1}
\makeatother
% -----
\renewcommand{\fboxsep}{1pt}%
% \let\processword\fbox
% \let\processword\underbar
\let\processword\uline
\begin{document}
\let\unexpanded\protected
\input{norm-tex.mkii} % upon \showmakeup - \normalvfil required
\input{supp-vis.mkiv}
\showmakeup
\unpacklipsum{1}{1}{\myflattenedlipsum}
% note: \processwords{\myflattenedlipsum} typesets in single line!
% must have at least a letter and a space, to cause per-word processing
% HOWEVER, \processwords{a \lipsum[1-2]} will *still* be typeset as one line!
% \processwords{a \myflattenedlipsum}
\processwords{P \myflattenedlipsum}
\unpacklipsum{2}{2}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}
\unpacklipsum{3}{4}{\myflattenedlipsum}
\processwords{P \myflattenedlipsum}
\end{document}
... and so results with the following, somewhat heavy rendering:

.... but at least I have a point of reference now, and a visual indication of row alignment in two column mode - but at the following expense:
\lipsum
paragraphs need to be expanded, and they cannot use \par
(so paragraphs must be manually reconstructed)
- Additionally, must add at least a letter to each
\lipsum
paragraph (to 'unpack' individual words)
- Typesetting according to hyphenation is not preserved.
One would think that it should be possible to capture the Tex box that represents a given row/line and simply fbox it (thus preserving hyphenation), but I tried looking at \tracingall, and I cannot see anything like that :) As for copying Context macros, I tried to copy in the macro for \underbars
- but that one is apparently a bit more complex; and there I'd get stuck with macros looking like \!!width
, which are apparently something Context-specific (meant for luatex maybe?), as Latex cannot seem to parse them; but I can see in @Aditya's edit, the !!
can be simply replaced with @@
for Latex.
Right, the earlier example I leave for reference (way below) - however, it actually does nothing; it uses seemingly the wrong \underbar
.
The good thing is - the Context visualisation macros (supp-vis.mkiv
) can indeed be used with plain (la)tex; unfortunately, the \underbar(s)
commands that underline each word/line are part of the core-fnt.mkii/mkiv
Context file, which requires a ton of Lua scripts - and I couldn't cheat it even with \usepackage{luatex}
and running lualatex
.
Nonetheless, here is a tex example which will use the Context visualisation macro, and is compilable with pdflatex
only:
\documentclass{article}
\usepackage[nopar]{lipsum}
% https://tex.stackexchange.com/questions/26806/expanding-edef-a-lipsum-command
\makeatletter
\def\unpacklipsum#1#2#3{%
\count@=#1\relax
\advance\count@\m@ne
\def#3{}%
\loop\ifnum\count@<#2\relax
\advance\count@\@ne
\edef#3{#3\csname lipsum@\romannumeral\count@\endcsname}%
\repeat}
\makeatother
\begin{document}
\let\unexpanded\protected
\input{norm-tex.mkii} % upon \showmakeup - \normalvfil required
\input{supp-vis.mkiv}
\showmakeup
% \showboxes % a bit tinier than \showmakeup
% \showframe % not in supp-vis
\unpacklipsum{1}{1}{\mycommand}
a \mycommand
\end{document}
(the output is similar to "visual debugging" example image of \showboxes
macro in @Aditya's answer)
OK, here's my attempt to use @Aditya's answer in Latex; after installing Context (tlmgr install context
); I was just trying to load some of its files "as if" they were packages - I got somewhere, with only partial success (can underline text; but only in a single line)... If anyone has an idea if it is impossible to go along this approach, that would be great to know.
Anyways, here is, say, 'test-con.tex
':
\documentclass{article}
\usepackage[nopar]{lipsum}
% https://tex.stackexchange.com/questions/26806/expanding-edef-a-lipsum-command
\makeatletter
\def\unpacklipsum#1#2#3{%
\count@=#1\relax
\advance\count@\m@ne
\def#3{}%
\loop\ifnum\count@<#2\relax
\advance\count@\@ne
\edef#3{#3\csname lipsum@\romannumeral\count@\endcsname}%
\repeat}
\makeatother
% \usepackage{contextcopy} % ! LaTeX Error: Missing \begin{document}. at l.740 \newskip \centering \centering....
% same Missing \begin{document} for below as well:
% \makeatletter
% \input{contextcopy.sty}
% \makeatother
\begin{document}
\makeatletter
\input{contextcopy.sty}
\makeatother
\unpacklipsum{1}{1}{\mycommand}
\underbar{Here \mycommand}
\end{document}
... and here is 'contextcopy.sty
':
% \input{/path/to/texlive/2011/texmf-dist/tex/context/base/supp-mis.mkii} % auto-read
\input{/path/to/texlive/2011/texmf-dist/tex/context/base/supp-pdf.mkii}
\input{/path/to/texlive/2011/texmf-dist/tex/context/base/syst-ini.mkii}
% \let\unexpanded\normalprotected % as in syst-aux.mkiv gives: ! Undefined control sequence.
% \let\unexpanded\relax %
\let\unexpanded\protect % same effect as \relax
\input{/path/to/texlive/2011/texmf-dist/tex/context/base/supp-vis.mkiv}
Funnily, even if I use pdflatex
, with this setup, it is a dvi
that gets generated:
$ pdflatex test-con.tex
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)
...
) (/path/to/texlive/2011/texmf-dist/tex/context/base/supp-vis.mkiv
loading: ConTeXt Support Macros / Visualization
))
Overfull \hbox (3454.36774pt too wide) in paragraph at lines 133--134
[]$[]$
[1] [2] (./test-con.aux) )
(see the transcript file for additional information)
Output written on test-con.dvi (2 pages, 1292 bytes).
Transcript written on test-con.log.
... and here is how xdvi
renders it:

Obviously, if it was possible to somehow load just the visualization stuff from Context, and otherwise build w/ plain pdflatex
, such that underlined multi-paragraph text is rendered, that would be awesome :) But I cannot tell if this sort of approach would eventually work..
Thanks again for all the responses,
Cheers!