LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Mime-Version:
1.0
Content-Type:
multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-AmWyFGi4PJDMxGp5/tmT"
Date:
Mon, 3 Aug 2015 14:18:57 +0200
Reply-To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Subject:
From:
Benjamin Berg <[log in to unmask]>
In-Reply-To:
Message-ID:
Sender:
Mailing list for the LaTeX3 project <[log in to unmask]>
Parts/Attachments:
text/plain (2491 bytes) , signature.asc (180 bytes)
Hi,

On Mo, 2015-08-03 at 12:04 +0100, David Carlisle wrote:
> On 03/08/2015 11:47, Benjamin Berg wrote:
> > I am having trouble to understand what the difference between
> > \addtocounter and \int_gincr:N is. When used inside a tabularx
> > environment, the \int_* functions do not work correctly, but the normal
> > LaTeX counters do.
> > 
> > Maybe the idea of even using counters in a tabularx environment like
> > this is totally wrong[1], but it feels to me like the two commands
> > should behave in the same way. So either I am not grasping some
> > concepts (feel free to just point me to an explanation) or there might
> > even be a small bug.
> > 
> > So, the attached document will print two tables. For each cell the
> > output of "\int_use:N \g_test_int,~\thetestcount" is displayed. The
> > counter is behaving as I expect while the \g_test_int has different
> > values inside tabularx.
> > 
> > 
> > tabularx:
> > 3, 1    4, 2    1, 3    2, 4
> > 3, 1    4, 2
> > 
> > and tabular:
> > 1, 1    2, 2    3, 3    4, 4
> > 1, 1    2, 2
> > 
> > It looks like this has to do with the fact that in the second row there
> > are empty cells. But it still baffles me, that the latex counters
> > behave correctly, while latex 3 integers do not.
> > 
> > Regards,
> > Benjamin
> > 
> > [1] It is very likely that I will drop the tabularx anyways.
> > 
> 
> 
> tabularx typesets its body multiple times with trial settings to find
> the right widths. So in general any command that is doing anything with
> global side effects like incrementing a counter will increment multiple
> times.
> 
> You would see the same with plain tex syntax \newcounter\foo.... if you use
> \global\advance\foo 1
> inside tabularx.
> 
> latex counters have a reset mechanism (designed for use with restoring
> counters after \include, mostly) tabularx uses this to restore all
> counters at the start of every trial setting.
> 
> \hfuzz is \maxdimen in trials so you can avoid incremengting counters
> during trials with
> 
> \ifdim\hfuzz<\maxdimen
> ...
> 
> but sometimes your code needs to increment and then restore, which is a
> bit more work.

Ah, now that makes a lot of sense, thanks for explaining! :)

I guess I was under the impression that tabularx required multiple
latex calls, instead of doing multiple trail runs during one latex run.
And I had no idea there was code to reset the global scope to some
extend.

Best solution for me will be to replace the tabularx use with a normal
tabular or even a tabbing environment.

Benjamin

ATOM RSS1 RSS2