Tag Info

New answers tagged

0

After posting, I discovered the MathJAX JavaScript library for (among other things) rendering TeX equations in MathML. I haven't yet had a chance to investigate in detail, but it handled with aplomb some aligns I had lying around. The code to parse TeX equations is as close to a grammar as anything I've seen. If you install a local copy, ...


7

\pdfmdfivesum also works on arbitrary strings: \pdfmdfivesum{Hello World} Result: B10A8DB164E0754105B7A99BE72E3FE5 The hex string can be decoded to save space: \pdfunescapehex{\pdfmdfivesum{Hello World}} \pdfmdfivesum is expandable and can be used inside \edef. \pdfmdfivesum works on file only, when the keyword file is given: \pdfmdfivesum file ...


2

Like this? You added \input at the wrong place, inside \linemark is where it should be. \documentclass{memoir} \usepackage[spacing, tracking]{microtype} \usepackage{libertine} \usepackage{xcolor} \usepackage{xspace} \nonfrenchspacing \microtypecontext{spacing=nonfrench} \newcounter{srcline} \newcommand{\linemark}{\stepcounter{srcline}% ...


6

A slight modification of Manuel's answer to track lines even across paragraph breaks. \documentclass{memoir} \usepackage{xcolor} \newcounter{srcline} \newcommand{\linemark}{\stepcounter{srcline}% \textcolor{red}{\textsc{Line~\thesrcline}}} % Playing with the gobbling of \par \makeatletter ...


15

Now that you added a new answer with all your requirements, I created an expl3 solution. This comes with an extra feature, that counts all lines (so if you leave two blank lines, then Line 6 Line 7 Line 8 are added). \documentclass{scrartcl} \usepackage{xparse,xcolor} \newcounter{srcline} \ExplSyntaxOn \NewDocumentEnvironment{scrlines} { } { \endgraf ...


9

I'm not sure how robust this solution is, but I simply redefine the catcode for the newline character to make it active, then append the new command to it. \documentclass{memoir} \usepackage{libertine} % want this font \usepackage{xcolor} % for color \usepackage{xspace} \newcounter{srcline} \newcommand{\linemark}{% \stepcounter{srcline}% ...


2

TeX's core engine does not use dynamically allocated memory but preallocated memory pools. So there's nothing like a heap to get dumped. The TeX base code does not provide a way to show the contents and pointers into the preallocated memory pools. So the answer to your question is: No, its impossible to generate a "usefull" TeX heap dump (which should be ...


5

Here's a LuaLaTeX-based solution: % !TEX TS-program = lualatex \documentclass{article} \begin{document} \newcommand\x{30} \newcommand\y{10} \textbackslash x divided by \textbackslash y is \directlua{tex.sprint(\x/\y)}. 2.5 multiplied by 4 is \directlua{tex.sprint(2.5*4)}. \end{document} If you need to do a lot of these simple divisions -- and other ...


4

You should absolutely use the eTeX \numexpr option; it's clear and is supported pretty much everywhere. If you're interested in the original Knuthian TeX, though, there are also arithmetical operators. For the four functions, you use the TeX primitives \advance, \multiply, and \divide, in a pretty unique and, I think, clever way: \documentclass{article} ...



Top 50 recent answers are included