Mr Arseneau if you come here ;-)
I try to put a listings environment inside varwidth and get
Failed to reprocess entire contents
If you compile the following example you can see
the box built by listings. It starts with \mathon ends
with \mathoff.
Besides, if I add colors, there are whatsits in the box...
In \@vwid@sift you say:
\ifnum\sift@deathcycles>33
\let\@vwid@sift\relax
\PackageWarning{varwidth}{Failed to reprocess entire contents}%
\fi
33 is written "hardly in the code" and I tried with 3333 but no success.
Do you think it would be possible for varwidth to get on with the
measure ? I've no idea ;-(
Thanks if you have a clue about where the barrier is.
% --------------------------------------------------------------
\documentclass [a4paper]{article}
\usepackage {listings,varwidth}
\begin{document}\makeatletter
\def\logbox #1{\begingroup
\edef\x{\endgroup \interactionmode \the\interactionmode\relax}%
\ifnum\tracingoutput>\z@ \ifnum\showboxdepth<10 \showboxdepth=10
\fi\ifnum\showboxbreadth<10 \showboxbreadth=10 \fi
\else \showoutput
\fi
\scrollmode \wlog{^^Jlogbox: #1}\showbox#1\x
}% \logbox
\setbox0=\hbox{%
\begin{varwidth}{\linewidth}
\begin{lstlisting}
a
\end{lstlisting}
\end{varwidth}
}
Varwidth box = \logbox0
\copy0
\end{document}\endinput
% --------------------------------------------------------------
> Failed to reprocess entire contents
I do not get that with your example.
Perhaps a newer listings puts inedible garbage in the
vertical list.
Anyway, with something like listings (which can put frames
around the listing) it should use the minumum width from the
start, not try to recover the state with varwidth.
--
Donald Arseneau as...@triumf.ca
Sorry my example didn't show the problem.
Yes for the minimum width: listings fits to \hsize.
I am inside a tabular: \hsize is given by the \@startpbox argument.
I finally found the culprit: \@finalstrut ! The rule inserted
prevents varwidth to finish its analyse...
Now it's fixed, and `tabu spread' works with lstlistings inside...
Good night.
> Le 26/03/2011 23:58, Donald Arseneau a écrit :
> > GL<goua...@gmail.com> writes:
> >
> >> Failed to reprocess entire contents
> >
> > I do not get that with your example.
> >
> > Perhaps a newer listings puts inedible garbage in the
> > vertical list.
> >
> > Anyway, with something like listings (which can put frames
> > around the listing) it should use the minumum width from the
> > start, not try to recover the state with varwidth.
>
> Sorry my example didn't show the problem.
Grumble gruumle.
> Yes for the minimum width: listings fits to \hsize.
It could do otherwise.
> I finally found the culprit: \@finalstrut ! The rule inserted
> prevents varwidth to finish its analyse...
It shouldn't (unless it is a redef of \@finalstrut; I presume
it puts \hrule in vertical mode).
--
Donald Arseneau as...@triumf.ca
I have to check. finstrut was loaded actually. And I didn't disable all
\@finalstrut in tabu cells when in trial-mode. Now this is done.
finstrut is interesting but it's not easy to know exactly which strut is
inserted depending on the options and the current mode. May be a
[verbose] option could help to report quickly: "finstrut: vertical mode
\pervdepth =-10000 inserted strut: .... "
Anyway tabu inserts only one strut per row: the \@arstrutbox and hence
is independant of finstrut. This allow to change the dimensions of the
\@arstrutbox at \everycr and thus alignment is far better then inside
tabular ! Well I have to finish the alignments tests... a long run test!
tabu [c] {p{..}} inside p column
tabu [c] {m{..}} inside p column
tabu [c] {b{..}} inside p column
tabu [c] {p{..}} inside m column
tabu [t] {b{..}} inside b column ...
( p + m + b ) x ( p + m + b ) x ( c + t + b ) =3^3=81 possibilities !
Yours sincerely.
Well here it is. Minimal. But in could not be \@finalstrut in fact,
for a rule in a box is a rule in a box, there is no more information
about what kind of rule it is (\vrule or \hrule)...
Finally the problem comes from xcolor. I suspect the whatsits...
\documentclass [a4paper]{article}
\usepackage {array}
\usepackage {listings,varwidth}
\usepackage {xcolor}
\begin{document}
\begin{tabular}{p{6cm}}
\begin{varwidth}\linewidth
\begin{lstlisting}
Test
\end{lstlisting}
\end{varwidth}
\end{tabular}
\end{document}\endinput
Yours sincerely
> Well here it is. Minimal. But in could not be \@finalstrut in fact,
> for a rule in a box is a rule in a box, there is no more information
> about what kind of rule it is (\vrule or \hrule)...
>
> Finally the problem comes from xcolor. I suspect the whatsits...
Still can't reproduce. I would have to suspect \pdfliteral and
a version of varwidth pre-2009.
I am getting an overfull hbox though.
--
Donald Arseneau as...@triumf.ca
\ProvidesPackage{varwidth}[2009/03/30 ver 0.92; \space
Variable-width minipages]
I did it again:
\documentclass [a4paper]{article}
\usepackage {array}
\usepackage {listings,varwidth}
\usepackage {xcolor}
\begin{document}
\font\cmr=cmr8 at 12pt \cmr
\begin{tabular}{p{6cm}}
\begin{varwidth}\linewidth
\begin{lstlisting}
Test
\end{lstlisting}
\end{varwidth}
\end{tabular}
\end{document}\endinput
Package varwidth Warning: Failed to reprocess entire contents on input
line 12.
Package varwidth Warning: Failed to reprocess entire contents on input
line 12.
No overfull... ???
Regards.
> I did it again:
Still no notification of:
> Package varwidth Warning: Failed to reprocess entire contents on input line
> 12.
with listings downloaded from ctan.
Enabling tracing shows that \special (for "latex") and
\pdfliteral (for "pdflatex") are safely protected.
This is pointless though and I won't waste more time on it.
varwidth is never going to shrink the width of the lines
emitted by the listings package, whether it sifts through
the vertical list or not.
--
Donald Arseneau as...@triumf.ca
No matter: please don't wait your time. tabu now works fine with
listings thank to varwidth, believe or not.
I mean tabu spread fits to the natural width of the listing
environment. May be varwidth is useless but :
1) like that the implementation is the same whether or not
the cell contains a lstlisting environment
2) varwidth usefull in case the cell does not contain only
a lstlisting environment:
\begin{tabu*}{ X[-1] X }
some text
\begin{lstlisting}
<some code>
\end{lstlisting} and some more text
&
The result of this listing is:\par
<some code>
\end{tabu*}
this works fine thank to varwidth package !
Regards.
in fact the way varwidth works is "minimal" example:
% -------------------------------------------------
\documentclass [a4paper]{article}
\usepackage {varwidth}
\begin{document}
\setbox777=\hbox{\vbox{Hy !\par}}
\tracingall\showoutput\scrollmode\showbox777
\setbox888=\hbox{\loggingall
\begin{varwidth}\hsize
\unhbox777
\end{varwidth}
}
\copy888
wd=\the\wd888 = \the\hsize
\tracingall\showoutput\scrollmode \showbox888
\end{document}\endinput
% -------------------------------------
the first box 777 is
> \box777=
\hbox(6.94444+1.94444)x345.0
.\vbox(6.94444+1.94444)x345.0
..\hbox(6.94444+1.94444)x345.0, glue set 311.11108fil
...\hbox(0.0+0.0)x15.0
...\OT1/cmr/m/n/10 H
...\OT1/cmr/m/n/10 y
...\glue 3.33333 plus 1.66666 minus 1.11111
...\OT1/cmr/m/n/10 !
...\penalty 10000
...\glue(\parfillskip) 0.0 plus 1.0fil
...\glue(\rightskip) 0.0
but varwidth does not "enter into" the \vbox does it ?
I thought about a loop that goes with \unkern\unskip\unpenalty
\lastbox until there is no more box...
Would it be possible ? (I think about the horizontal glues and I
wonder if it would be possible...)
Thanks.
> but varwidth does not "enter into" the \vbox does it ?
>
> I thought about a loop that goes with \unkern\unskip\unpenalty
> \lastbox until there is no more box...
\lastwrite, \lastspecial, \lastwhatsit, ... are not available in TeX.
You can use LuaTeX and program it in Lua.
--
Heiko Oberdiek
Yes but Lua is not used by everybody...
The point is that the width of a piece of text does not depend on
whatsits ! Then in some special cases, it's possible to disable the
whatsits. This is what I do for colors in the lstlisting environment,
and varwidth is able to give me the "natural width".
After that, restore the colors and print with the natural width varwidth
kindly told me ;-)
Thanks.
> Le 30/03/2011 14:48, Heiko Oberdiek a écrit :
> > GL<goua...@gmail.com> wrote:
> >
> >> but varwidth does not "enter into" the \vbox does it ?
> >>
> >> I thought about a loop that goes with \unkern\unskip\unpenalty
> >> \lastbox until there is no more box...
> >
> > \lastwrite, \lastspecial, \lastwhatsit, ... are not available in TeX.
> > You can use LuaTeX and program it in Lua.
>
> Yes but Lua is not used by everybody...
>
> The point is that the width of a piece of text does not depend on
> whatsits !
I doubt you want to exclude images?
--
Heiko Oberdiek
They are seldom used inside Verbatim or lstlisting environment !
> in fact the way varwidth works is "minimal" example:
I do know how varwidth work in fact.
> but varwidth does not "enter into" the \vbox does it ?
No it does not dig down into vboxes, or nested hboxes,
and it surely will not do so: that would break far more
than it fixes.
--
Donald Arseneau as...@triumf.ca
varwidth handles the indigestible nodes by packing them in boxes
for the first "measuring" pass through the vertical list, and
unwrapping them on the second "typesetting" pass. You *might*
be able to do something like that if you were sifting through
the contents of each and every box, but it wouldn't be pretty.
--
Donald Arseneau as...@triumf.ca
Hopefully ;-)
>> but varwidth does not "enter into" the \vbox does it ?
>
> No it does not dig down into vboxes, or nested hboxes,
> and it surely will not do so: that would break far more
> than it fixes.
Yes I was expected such an answer. I think it's not possible
to "destroy" and "rebuilt" the horizontal lists...
Thanks.