[l2h] non-integer calculations -- any way to do this?
bmassing at cs.trinity.edu
bmassing at cs.trinity.edu
Fri Apr 5 18:35:18 CEST 2019
First, I agree that it doesn't seem feasible for latex2html to
implement all of TeX.
Below is a short simple program showing my current macros and
usage. I wrote the macros a long time ago, and on looking at
them again, they're kind of ugly. But they get the job done --
as long as I only want to use integers. That's starting to
feel restrictive.
There are various options for doing arithmetic on floating-point
values, including what seem to be a variety of LaTeX packages.
It occurs to me, however, that very likely none of them will do
what I want to, *because* I want to be able to print the total
at the top of the document. My current macros can do that using
\refstepcounter and \label, but I don't think any of the LaTeX
packages I've looked at would do that.
More and more I think I need to just write a preprocessor! "How
hard can it be" .... :-)?
==== start of .tex file ====
\documentclass{article}
% ---- macros ----
\newcounter{Tpoints}
\setcounter{Tpoints}{0}
\newcommand{\EndAll}{
\addtocounter{Tpoints}{-1}
\refstepcounter{Tpoints}
\label{tpoints}
}
\newcommand{\Points}[1]{
({#1} points)
\addtocounter{Tpoints}{#1}
}
% ---- document ----
\begin{document}
Total credit: \ref{tpoints} points.
\begin{enumerate}
\item \Points{10} Do this problem.
\item \Points{30} Do that problem.
\end{enumerate}
\EndAll
\end{document}
==== end of .tex file ====
-- blm
On Fri, Apr 05, 2019 at 08:19:48AM +0300, Сергей Знаменский wrote:
>>
>> Dear bmassing at cs.trinity.edu!
>>
>> True TeX syntax is too complicated to be fully implemented
>> in convertors like latex2html. Only the most sensitive features
>> can be supported.
>>
>> In order to recommend some approach the simple usage examples
>> (TeX source fragment with desirable text/HTML results) are
>> necessary.
>>
>> Would You like to provide simple examples of what You'd like to get?
>>
>> Yours, Sergej
>>
>> > ----- Original Message -----
>> > From: bmassing at cs.trinity.edu
>> > To: latex2html at tug.org
>> > Sent: Thu, 4 Apr 2019 17:47:59 -0500
>> > Subject: [l2h] non-integer calculations -- any way to do this?
>> >
>> > I have a set of macros I originally wrote only for LaTeX that
>> > do some primitive calculations, calculating a runniing total
>> > using LaTeX's counter mechanism. At some point I started using
>> > these macros with TeX source to be processed with latexh2ml.
>> > They seem to work fine, but now I'd like to revise the macros to
>> > support non-integer values for the running total. It looks like
>> > there are many options for doing this in LaTeX, but no surprise,
>> > I'm not finding anything that latex2html can deal with properly.
>> > So:
>> >
>> > Can anyone think of a way to easily do this? perhaps a
>> > latex2html-friendly LaTeX package?? (This seems unlikely,
>> > but might as well ask?)
>> >
>> > If that's not feasible, I'm thinking that if I get really
>> > determined I could try to tweak latex2html, but I can't figure
>> > out where to start! Documentation says it provides some
>> > primitive support for plain-TeX commands such as \newdimen,
>> > but I'm sure not finding anyplace in the source that does that. ?
>> >
>> > Or maybe there's some totally different approach I could use
>> > instead? pre-processing the source, post-processing the result .... ?
>> >
>> > Suggestions appreciated!
>> >
>> > -- blm
>> >
--
-----------------------------------------------------------------
Dr. Berna L. Massingill
Associate Professor, Computer Science
Trinity University
One Trinity Place; San Antonio, TX 78212-7200
210-999-8138
bmassing at cs.trinity.edu
-----------------------------------------------------------------
More information about the latex2html
mailing list