Re: datatool with siunitx (and numprint)



On Aug 20, 9:49 am, t.m.trzec...@xxxxxxxxx wrote:

Could you reverse that logic and instead have a list of commands that
should not be expanded? One could also prevent expansion manually with
\noexpand or \protect where necessary. Why expanding by default would
be a bad thing?

I've inherited the method used in siunitx from rccol, although I hope
I've improved it a little. If you look at the code (search for
\si@tab@gettok@S, line 2339 in 1.0i) you will see there are a number
of "special case" macros that are swept up unexpanded. I've basically
taken these on trust, so perhaps this caution is not needed.

I've tried a few tests with expanding the contents after removing the
above special cases. A bit of care is needed, as with two passes
things like "{title text}" will need to only be processed once
(otherwise the braces are lost and the "e" is mistaken for an exponent
marker!). That is of course do-able. More problematic is the case in
hand. Try doing \edef or \protected@edef with \DTLround:

\documentclass{article}
\usepackage{datatool}
% Build database.
\DTLnewdb{data}
\DTLnewrow{data}\DTLnewdbentry{data}{value}{66.7012}
\DTLnewrow{data}\DTLnewdbentry{data}{value}{66.0212}
\DTLnewrow{data}\DTLnewdbentry{data}{value}{65.275466666667}
\DTLnewrow{data}\DTLnewdbentry{data}{value}{64.9026}
\DTLnewrow{data}\DTLnewdbentry{data}{value}{44.529733333333}
\begin{document}
\DTLforeach{data}{\value=value}{\DTLround{\value}{\value}{5}\value\\}
\makeatletter
\DTLforeach{data}{\value=value}{\protected@edef\temp{\DTLround{\value}
{\value}{5}\value\\}}
\end{document}

So I'm not sure how I can ensure that the cell contents are fully
expanded in a way that is safe, apart from simply typesetting any
"other" contents and hoping that this works.

I'm reluctant to make a change to the underlying mechanism unless it
helps with the point in hand. Suggestions welcome!
--
Joseph Wright

.



Relevant Pages

  • Re: A problem with picins and/or collect@body
    ... of those commands will fail. ... precise rules as what needs expanding and what needn't. ... environment, taking an optionnal parameter, precising where to put the ... I didn't find a package that would work for all ...
    (comp.text.tex)
  • An explanation for the increasing expansion
    ... collapsing mass and expanding energy. ... would have to exceed C to reverse this slowing. ...
    (sci.physics)
  • Re: streamer clouds
    ... asking about the low-level cloud that is skinny through the right two-thirds of the photo, expanding into a larger formation to the left one-third. ... "Never trust anything that can think for itself, ...
    (rec.aviation.piloting)
  • Using a single SMS server for 2 domains with no trust
    ... We're currently expanding our SMS discovery to include another domain. ... domain has no trust with our primary domain as they're not in the same ...
    (microsoft.public.sms.setup)