[l2h] non-integer calculations -- any way to do this?
bmassing at cs.trinity.edu
bmassing at cs.trinity.edu
Fri Apr 5 20:30:40 CEST 2019
By "preprocessor" I don't mean something at all general; I mean
something that does pretty much what you suggest. So to adapt my
example below, there would be a .tex_in file that looks something
like this:
\begin{document}
Total credit: \TOTALPOINTS points.
\begin{enumerate}
\item POINTS{10} Do this problem.
\item POINTS{30} Do that problem.
\end{enumerate}
\end{document}
and a preprocessor that would somehow turn this into two files,
two .tex files:
==== main file ====
\include{defs.tex}
\begin{document}
Total credit: \TOTALPOINTS points.
\begin{enumerate}
\item (10 points) Do this problem.
\item (30 points) Do that problem.
\end{enumerate}
\end{document}
==== defs.tex ====
\def\TOTALPOINTS{40}
====
and then, as you suggest, use "make" to automate doing this
preprocessing step before it runs latex and/or latex2html.
I admit I haven't thought this through in any depth, but to me it
seems promising, and this program to do the preprocessing -- I've
written a lot of programs that I think have similar functionality.
-- blm
On Fri, Apr 05, 2019 at 10:39:59AM -0700, Bob van der Poel wrote:
>>
>> I am far (very far!) from being a tex expert ... but could you not use a
>> 2ndary program to do the calculations and format them into something tex
>> understands and then \include that result into the main
>> tex/latex/latex2html files? Wrap it all together in a makefile and you're
>> done. Much easier, thinks I, than writing a pre-processor :)
>>
>> On Fri, Apr 5, 2019 at 9:35 AM <bmassing at cs.trinity.edu> wrote:
>>
>> > 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
>> > -----------------------------------------------------------------
>> > _______________________________________________
>> > latex2html mailing list
>> > latex2html at tug.org
>> > https://tug.org/mailman/listinfo/latex2html
>> >
>>
>>
>> --
>>
>> **** Listen to my FREE CD at http://www.mellowood.ca/music/cedars ****
>> Bob van der Poel ** Wynndel, British Columbia, CANADA **
>> EMAIL: bob at mellowood.ca
>> WWW: http://www.mellowood.ca
--
-----------------------------------------------------------------
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