Received: from mx0.gmx.net (mx0.gmx.net [213.165.64.100]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with SMTP id p04AX7Uq003772 for ; Tue, 4 Jan 2011 11:33:09 +0100 Received: (qmail 31067 invoked by alias); 4 Jan 2011 10:33:01 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 04 Jan 2011 10:33:01 -0000 Received: from relay.uni-heidelberg.de (EHLO relay.uni-heidelberg.de) [129.206.100.212] by mx0.gmx.net (mx026) with SMTP; 04 Jan 2011 11:33:01 +0100 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id p04AV7EP005009 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 4 Jan 2011 11:31:08 +0100 Received: from listserv.uni-heidelberg.de (localhost.localdomain [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id p049qcID001020; Tue, 4 Jan 2011 11:30:58 +0100 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 779092 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 4 Jan 2011 11:30:58 +0100 Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.210.211]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id p04AUwJw003118 for ; Tue, 4 Jan 2011 11:30:58 +0100 Received: from mail-fx0-f49.google.com (mail-fx0-f49.google.com [209.85.161.49]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id p04AUjut029789 for ; Tue, 4 Jan 2011 11:30:49 +0100 Received: by fxm19 with SMTP id 19so13757476fxm.22 for ; Tue, 04 Jan 2011 02:30:45 -0800 (PST) Received: by 10.223.101.195 with SMTP id d3mr713150fao.21.1294137045453; Tue, 04 Jan 2011 02:30:45 -0800 (PST) Received: from irwin.vpn.uni-freiburg.de (p5484721A.dip.t-dialin.net [84.132.114.26]) by mx.google.com with ESMTPS id c11sm5031011fav.26.2011.01.04.02.30.44 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 04 Jan 2011 02:30:44 -0800 (PST) Received: by irwin.vpn.uni-freiburg.de (Postfix, from userid 500) id CD278800A; Tue, 4 Jan 2011 11:27:43 +0100 (CET) Mail-Followup-To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE References: <4D22486F.5000506@morningstar2.co.uk> <7C89B4BA-13CE-4976-ADB9-1C08CE25475E@gmail.com> <20110104084343.GA7767@oberdiek.my-fqdn.de> <4D22E7E0.9030700@morningstar2.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Message-ID: <20110104102742.GA8247@oberdiek.my-fqdn.de> Date: Tue, 4 Jan 2011 11:27:43 +0100 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Heiko Oberdiek Subject: Re: \box_if_empty:N(TF) To: LATEX-L@listserv.uni-heidelberg.de In-Reply-To: <4D22E7E0.9030700@morningstar2.co.uk> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=5D7Q89H36p6i75npGen84eVAEFK/syJmFuaL1OLtauwJ5R/kaZ9HAe8peGX1DeqJL7BW4 1X28hmBsSaikXt0ebYfUaHmtXkk7HChP+4IT8t5foOuRzC8vyH8YP07l+7OgkY63m+qRZCiPVOZg mL0OA==V1; X-Resent-By: Forwarder X-Resent-For: rainer.schoepf@gmx.net X-Resent-To: rainer@rainer-schoepf.de Status: R X-Status: X-Keywords: X-UID: 6520 Hello, On Tue, Jan 04, 2011 at 09:26:56AM +0000, Joseph Wright wrote: > > [empty box test] > > Thanks for that Heiko: quite a nice idea. One obvious conceptual > question is how to treat void boxes. You've gone for 'void boxes are > not empty', but this might not be how everyone expects it to be. The example was just a ``proof of concept''. A solution without global assignments, without a new box register and with void as empty: \NeedsTeXFormat{LaTeX2e} \makeatletter % empty := empty \(h|v)box | void \def\ifboxempty#1{% \begingroup \ifvoid#1% \let\@next\@firstoftwo \else \let\@next\@secondoftwo \def\@nextempty{\let\@next\@firstoftwo}% \ifhbox#1% \setbox\z@=\hbox{% \unhcopy#1\relax \ifnum\lastnodetype<\z@ \aftergroup\@nextempty \fi }% \else \ifvbox#1% \setbox\z@=\vbox{% \unvcopy#1\relax \ifnum\lastnodetype<\z@ \aftergroup\@nextempty \fi }% \fi \fi \fi \expandafter\endgroup \@next } \makeatother \def\wrong#1{\typeout{WRONG: #1}} \def\ok#1{\typeout{OK: #1}} \begingroup \setbox0=\box0 \endgroup \ifboxempty0{\ok{void is empty}}{\wrong{void is not empty}} \setbox0=\null \ifboxemptyorvoid0{\ok{null is empty}}{\wrong{null is not empty}} \setbox0=\vbox{} \ifboxempty0{\ok{vbox{} is empty}}{\wrong{vbox{} is not empty}} \setbox0=\hbox{\write16{}} \ifboxempty0{\wrong{hbox with write is empty}}% {\ok{hbox with write is not empty}} \csname @@end\endcsname\end In an exact manner of speaking the question if a box is empty without having a box is wrong itself. On the other hand a user might be only interested, if there is box contents. But in the end this is a matter of definition and naming the macro. Yours sincerely Heiko