Discussion:
varwidth
(too old to reply)
GL
2011-03-26 17:33:37 UTC
Permalink
Hello,

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 \@***@sift you say:

\ifnum\***@deathcycles>33
\let\@***@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
% --------------------------------------------------------------
Donald Arseneau
2011-03-26 22:58:53 UTC
Permalink
Post by GL
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 ***@triumf.ca
GL
2011-03-27 02:21:00 UTC
Permalink
Post by Donald Arseneau
Post by GL
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.

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.
Donald Arseneau
2011-03-28 10:11:34 UTC
Permalink
Post by GL
Post by Donald Arseneau
Post by GL
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.
Post by GL
Yes for the minimum width: listings fits to \hsize.
It could do otherwise.
Post by GL
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 ***@triumf.ca
GL
2011-03-28 10:42:03 UTC
Permalink
Post by Donald Arseneau
Post by GL
Post by Donald Arseneau
Post by GL
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.
Post by GL
Yes for the minimum width: listings fits to \hsize.
It could do otherwise.
Post by GL
prevents varwidth to finish its analyse...
it puts \hrule in vertical mode).
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.
GL
2011-03-28 10:52:08 UTC
Permalink
Post by Donald Arseneau
Post by GL
Post by GL
Failed to reprocess entire contents
Sorry my example didn't show the problem.
Grumble gruumle.
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
Donald Arseneau
2011-03-28 21:23:37 UTC
Permalink
Post by GL
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 ***@triumf.ca
GL
2011-03-28 22:07:03 UTC
Permalink
Post by Donald Arseneau
Post by GL
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.
\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.
Donald Arseneau
2011-03-29 18:19:30 UTC
Permalink
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 ***@triumf.ca
GL
2011-03-29 18:48:39 UTC
Permalink
Post by Donald Arseneau
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.
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.

Loading...