Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CTAN package update: Herbert Voss's mathmode

15 views
Skip to first unread message

CTAN Announcements

unread,
Oct 6, 2006, 7:18:31 AM10/6/06
to ctan...@dante.de
Herbert Voss writes:

> Mathmode.pdf is a comprehensive review of mathematics in (La)TeX.
> This new version 2.19 has the following changes:
>
> - some more infos for the fleqn class option
> - small fixes to the array environment
> - added an example for gathered (ams) and
> for boxed rows and columns of arrays
> - indice in upright font shape
> - extended index
> - a lot of modifications to the source code

i have installed the new version at cambridge, and pushed it out to
the rest of the world.

users may browse the new version via its catalogue page:

http://www.tex.ac.uk/tex-archive/help/Catalogue/entries/voss-mathmode.html

thanks, herbert, for the upload.

Robin Fairbairns

For the CTAN team

Jonathan Fine

unread,
Oct 6, 2006, 10:01:27 AM10/6/06
to
Was: Re: CTAN package update: Herbert Voss's mathmode

"CTAN Announcements" <ctan...@dante.de> wrote in message
news:mailman.0.1160133...@dante.de...


> Herbert Voss writes:
>
> > Mathmode.pdf is a comprehensive review of mathematics in (La)TeX.

Here's the file:
http://www.tex.ac.uk/tex-archive/info/math/voss/mathmode/Mathmode.pdf

I used Acrobat to select the source for one of the
sample equations, and pasted it into the posting.

This is what I got:
\(\ sum _{i =1}^{ n}i=\ frac {1}{2} n\ cdot (n+1) \)

This is not what I was expecting. It probably has something
to do with the control sequence names being in a different
colour in the PDF file.

Here's a general problem. How can I put an equation
into a PDF file, in such a way that selecting the
equation gives me the TeX source for the equation.

Has this problem been solved already? Do the tools
for doing it already exist?

--
Jonathan


Maarten

unread,
Oct 6, 2006, 10:08:01 AM10/6/06
to
Jonathan Fine wrote:
> Here's a general problem. How can I put an equation
> into a PDF file, in such a way that selecting the
> equation gives me the TeX source for the equation.

Pure verbatim (Sorry, LaTeX parlance, translate to TeX yourself) can do
this AFAIK, although some fiddling with input encodings and especially
fontencoding may be needed.

> Has this problem been solved already? Do the tools
> for doing it already exist?

The cleanest way I think is to attach small files with the source to
the pdf file, this guarantees the same contents. There are are packages
to do this for LaTeX, I'm sure the sources can be reused in TeX.

Maarten

Jonathan Fine

unread,
Oct 6, 2006, 11:31:41 AM10/6/06
to
"Maarten" <maarte...@knmi.nl> wrote in message
news:1160143680.9...@c28g2000cwb.googlegroups.com...

Thank you for this. Perhaps someone could help
me further by providing an example.

For example, a single page PDF document containing
the typeset formula
x^2 + y^2 = z^2
such that selecting and pasting the document produces
x^2 + y^2 = z^2
or perhaps something like
\[ x^2 + y^2 = z^2 \]

I'm not much bothered if it is LaTeX or plain TeX.

If I had that as a starting point, this would be
very helpful.

--
Jonathan


Scott Pakin

unread,
Oct 6, 2006, 6:56:19 PM10/6/06
to
Jonathan Fine wrote:
> Here's a general problem. How can I put an equation
> into a PDF file, in such a way that selecting the
> equation gives me the TeX source for the equation.
>
> Has this problem been solved already? Do the tools
> for doing it already exist?

You can be really clever and use PDF's "replacement text" feature:

\documentclass[12pt]{article}

\begin{document}

\bgroup
\lccode`!=`\\
\lowercase{\gdef\esc{!!}}
\egroup

You can easily write equations such as
\pdfliteral direct {%
/Span <<
/ActualText (\esc( \esc sum_{i=1}^{n}i = \esc frac{1}{2}n \esc cdot (n+1) \esc))
>>
BDC
}
\(\sum_{i=1}^{n}i=\frac{1}{2}n\cdot(n+1)\)
\pdfliteral direct {%
EMC
}
in \LaTeX.

\end{document}

For some reason, the selected region looks odd (more specifically, disjoint),
at least in Acrobat Reader 7.0.8 for Linux. However, "replacement text"
does seem to be an appropriate mechanism for showing one thing on the page
but storing something else in the copy buffer.

-- Scott

Jonathan Fine

unread,
Oct 7, 2006, 6:33:56 AM10/7/06
to

Thank you very much for this, Scott. Most helpful.

I'll look at it further on Monday, when I'm back at
work.

I wonder if anyone has wrapped this up in a macro package?

This google search
http://www.google.com/search?num=50&hl=en&lr=&q=latex++ActualText
produces only 7 hits, so I think not.

One of the hits is EuroTeX 2005:
Omega Becomes a Sign Processor, Yannis Haralambous, Gabor Bella

And once again, thank you, Scott.

--
Jonathan

Jonathan Fine

unread,
Oct 9, 2006, 7:13:02 AM10/9/06
to
"Scott Pakin" <scot...@pakin.org> wrote

> You can be really clever and use PDF's "replacement text" feature:

[lovely working example snipped]


Thank you very much for this, Scott.

Here's a plain pdfTeX file, based on your example, that
works (but ...)
===
\def\strip #1:->{}

\def\pasteandprint #1%
{%
\def\temp{#1}%
\edef\temp{\expandafter\strip\meaning\temp}
\pdfliteral direct{/Span << /ActualText (\temp) >> BDC }%
#1%
\pdfliteral direct{EMC }%
}


\pasteandprint{$x^2 + y^2 = z^2$}

\pasteandprint{hello world}

{\tt\pasteandprint{hello world}}

{\tt\pasteandprint{ABCCD}}

{\tt\pasteandprint{ABCDE}}

\end
===

When I cut and paste the content I get
===
$x^2 + y^2 = z^2$
helo world
helo world
ABCD
ABCDE
===

I really like the first line. Spot on the money.

Note that "hello" -> "helo", and "ABCCD" -> "ABCD".

I'm using
pdfTeX, Version 3.141592-1.11b (MiKTeX 2.4)
Adobe Reader 7.0.5 on Windows 2000

I've not yet looked into the Acrobat bug reports.

--

Jonathan


Morten Høgholm

unread,
Oct 9, 2006, 10:12:35 AM10/9/06
to
On Mon, 09 Oct 2006 13:13:02 +0200, Jonathan Fine <J.F...@open.ac.uk>
wrote:

> Thank you very much for this, Scott.

Indeed - this is a cool feature.

> Here's a plain pdfTeX file, based on your example, that
> works (but ...)
> ===
> \def\strip #1:->{}
>
> \def\pasteandprint #1%
> {%
> \def\temp{#1}%
> \edef\temp{\expandafter\strip\meaning\temp}
> \pdfliteral direct{/Span << /ActualText (\temp) >> BDC }%

You can use
\pdfescapestring{\unexpanded{#1}}
instead. This also doubles the backslashes as they should for copy-pasting
purposes.

> \pasteandprint{hello world}
[...]


> Note that "hello" -> "helo", and "ABCCD" -> "ABCD".
>
> I'm using
> pdfTeX, Version 3.141592-1.11b (MiKTeX 2.4)
> Adobe Reader 7.0.5 on Windows 2000

Same problem with Adobe Reader 7.0.8 on OS X 10.4.8 using pdfeTeX 1.30.4.
The pdf is correct as can be checked with \pdfcompresslevel=0. It doesn't
help to produce a pdf1.6 file.

This method should be fairly easy to add to math packages doing multiple
passes on the displays. I'll add this to empheq next time I do an update.
--
Morten

Jonathan Fine

unread,
Oct 9, 2006, 11:14:31 AM10/9/06
to
"Morten Høgholm" <morten....@gmail.com> wrote in message
news:op.tg5q2...@morten.local...
===

You can use
\pdfescapestring{\unexpanded{#1}}
instead. This also doubles the backslashes as they should for copy-pasting
purposes.

> \pasteandprint{hello world}
[...]
> Note that "hello" -> "helo", and "ABCCD" -> "ABCD".
>
> I'm using
> pdfTeX, Version 3.141592-1.11b (MiKTeX 2.4)
> Adobe Reader 7.0.5 on Windows 2000

Same problem with Adobe Reader 7.0.8 on OS X 10.4.8 using pdfeTeX 1.30.4.
The pdf is correct as can be checked with \pdfcompresslevel=0. It doesn't
help to produce a pdf1.6 file.

This method should be fairly easy to add to math packages doing multiple
passes on the displays. I'll add this to empheq next time I do an update.

===

Thank you, Morten, for checking it out on your Mac.
It's something I'd like to have fixed.

Ideally, one would want this capability to be, so to
speak, built into the LaTeX kernel or whatever.

So that one could cut LaTeX code from a PDF,
and paste it into a LaTeX document.

Another challenge, in another post, is to get
the screen reader to use alternative text.

--
Jonathan


Jonathan Fine

unread,
Oct 9, 2006, 11:20:35 AM10/9/06
to
Was Re: Selecting sample text from a PDF and pasting it into a TeX document

I would like a macro \typeandspeak, that takes two
parameters such that this input:
===
\typesetandspeak


{$x^2 + y^2 = z^2$}

{x squared plus y squared equals z squared}
===
produces as output

a) the typeset equation in the PDF (easy
so far),

b) when the equation is read in the PDF screen
reader one gets, well
"x squared plus y squared equals z squared"

In fact, never mind the specific input, I'd be
delighted if I could see any sort of TeX input
that would produce the desired output.

Anyone interested in this? It's very important
for solving accessibility problems.

--
Jonathan


Morten Høgholm

unread,
Oct 9, 2006, 11:33:20 AM10/9/06
to
On Mon, 09 Oct 2006 17:20:35 +0200, Jonathan Fine <J.F...@open.ac.uk>
wrote:

> I would like a macro \typeandspeak, that takes two


> parameters such that this input:
> ===
> \typesetandspeak
> {$x^2 + y^2 = z^2$}
> {x squared plus y squared equals z squared}
> ===
> produces as output
>
> a) the typeset equation in the PDF (easy
> so far),
>
> b) when the equation is read in the PDF screen
> reader one gets, well
> "x squared plus y squared equals z squared"
>
> In fact, never mind the specific input, I'd be
> delighted if I could see any sort of TeX input
> that would produce the desired output.
>
> Anyone interested in this? It's very important
> for solving accessibility problems.

Have you looked at the work of T.V. Raman?
--
Morten

Heiko Oberdiek

unread,
Oct 9, 2006, 11:40:37 AM10/9/06
to
"Jonathan Fine" <J.F...@open.ac.uk> wrote:

> Ideally, one would want this capability to be, so to
> speak, built into the LaTeX kernel or whatever.

TeX is a macro language. How does the kernel know,
which level of expansion it should use?

> So that one could cut LaTeX code from a PDF,
> and paste it into a LaTeX document.

What about macros and packages? E.g., one of the documents uses
amsmath, the other doesn't?

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Jonathan Fine

unread,
Oct 9, 2006, 12:10:15 PM10/9/06
to
"Morten Høgholm" <morten....@gmail.com> wrote in message
news:op.tg5ut...@morten.local...

> Have you looked at the work of T.V. Raman?

Yes. I've known about it for over 10 years.

One of the most recent items I could find is
http://www.springerlink.com/content/p573032hl5t4r2xl/
http://www.springerlink.com/content/p573032hl5t4r2xl/fulltext.pdf

As I understand it, his goal is to translate
LaTeX into audio. This is his Aster system.

My goal is to embed text into a PDF so that
a screen reader will pick it up.

The text that I embed might be generated by
Aster, or a similar program. But that is not
my concern at present.

My goal is to solve a particular technical
problem in the generation of PDF files. The
process of translating math to text is
assumed to be done elsewhere.

I'd be delighted to hear that the problem has
already been solved.

--
Jonathan


Jonathan Fine

unread,
Oct 9, 2006, 12:32:50 PM10/9/06
to
"Heiko Oberdiek" <ober...@uni-freiburg.de> wrote in message
news:egdqhk$i4c$1...@news.BelWue.DE...

> "Jonathan Fine" <J.F...@open.ac.uk> wrote:
>
> > Ideally, one would want this capability to be, so to
> > speak, built into the LaTeX kernel or whatever.
>
> TeX is a macro language. How does the kernel know,
> which level of expansion it should use?

The simplest, and perhaps best, solution is that
you get the source text for the selection.

It's certainly a fine starting point.


> > So that one could cut LaTeX code from a PDF,
> > and paste it into a LaTeX document.
>
> What about macros and packages? E.g., one of the documents uses
> amsmath, the other doesn't?

Well, the document won't compile correctly
until that problem has been fixed. That's
fine. Same happens when one cuts and pastes
C source files. Same as cutting and pasting
when the fonts are not available.

--
Jonathan


David Kastrup

unread,
Oct 9, 2006, 1:56:13 PM10/9/06
to
"Jonathan Fine" <J.F...@open.ac.uk> writes:

> "Heiko Oberdiek" <ober...@uni-freiburg.de> wrote in message
> news:egdqhk$i4c$1...@news.BelWue.DE...
>> "Jonathan Fine" <J.F...@open.ac.uk> wrote:
>>
>> > Ideally, one would want this capability to be, so to
>> > speak, built into the LaTeX kernel or whatever.
>>
>> TeX is a macro language. How does the kernel know,
>> which level of expansion it should use?
>
> The simplest, and perhaps best, solution is that
> you get the source text for the selection.
>
> It's certainly a fine starting point.

The problem is that there often is no corresponding source text for
the selection.

For example, if I select the word

\footnote{Here is some larger ->text<- in context}

what is the corresponding source text? Presumably the input file
position before "text" is being typeset, to the input file position
after "text" is being typeset. Which _both_ happen to be immediately
after the closing brace, since \footnote in LaTeX is (in contrast to
its plain TeX cousin) defined as a macro taking an argument (well,
unless you use bigfoot.sty).

A _lot_ in LaTeX is implemented via macro calls with arguments, and in
all those cases, the input position before and after typesetting a
particular phrase tend to be identical: after the last macro argument.

preview-latex
<URL:http://www.gnu.org/software/auctex/preview-latex.html> has to
solve the same sort of correspondence problem (though not on the scale
of a whole document at character granularity), and it messes
considerably with the typesetting process in order to do this. The
dvi/pdf file layout becomes quite different in the process, so this is
not completely comparable, but the situation is pretty much the same:
TeX's input position is snapshotted at strategic points. Only that
those points are while _macro_ processing, not while actually
typesetting or shipping material.

--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
UKTUG FAQ: <URL:http://www.tex.ac.uk/cgi-bin/texfaq2html>

Jonathan Fine

unread,
Oct 9, 2006, 2:16:06 PM10/9/06
to
David Kastrup wrote:

> The problem is that there often is no corresponding source text for
> the selection.
>
> For example, if I select the word
>
> \footnote{Here is some larger ->text<- in context}
>
> what is the corresponding source text?

Well, "text", obviously. If you, as you say, select
a word, then the selection is that word.


> Presumably the input file
> position before "text" is being typeset, to the input file position
> after "text" is being typeset. Which _both_ happen to be immediately
> after the closing brace, since \footnote in LaTeX is (in contrast to
> its plain TeX cousin) defined as a macro taking an argument (well,
> unless you use bigfoot.sty).

Well, that's clearly not the way to do things.

This matter is not rocket science. Word can do it.

--
Jonathan

David Kastrup

unread,
Oct 9, 2006, 2:55:37 PM10/9/06
to
Jonathan Fine <jf...@pytex.org> writes:

If you are in possession of the wisdom how to do things, feel free
doing them.

> This matter is not rocket science. Word can do it.

Then I suggest that you use Word for your application instead of an
input language based on an extensive macro-processing system. I have
my doubts that Word will be able to properly identify the source for
algorithmically created content, but I am not in possession of a copy
of it in order to check.

If I select

->Chapter 1<-

At the Beginning

do I want to get
\chapter{At the Beginning}

or rather

\if@openright\cleardoublepage\else\clearpage\fi
\thispagestyle{plain}%
\global\@topnum\z@
\@afterindentfalse
\secdef\@chapter\@schapter

Or maybe
\@makechapterhead{At the Beginning}

or just

\huge\bfseries \@chapapp\space \thechapter


You claim that one should not consult the corresponding input stream
positions at the time of typesetting. But the corresponding input
stream position at the time where the respective tokens were generated
are not really the hottest thing on Earth, either. In particular,
they make it _quite_ impossible to paste some source code together
again from linearly cut&pasted pieces.

Jonathan Fine

unread,
Oct 9, 2006, 3:36:05 PM10/9/06
to
David Kastrup wrote:

>>This matter is not rocket science. Word can do it.
>
>
> Then I suggest that you use Word for your application instead of an
> input language based on an extensive macro-processing system.

I do not wish to use Word for mathematical typesetting. It's
rubbish at that.

I am not suggesting that TeX users should switch to Word.

However, I am suggesting that TeX developers should learn
from Word. And from Word users.

And anyway, surely Word and LaTeX-like can't be the
only possible choices.

However, at this point I think we are well off-topic.

--
Jonathan

David Kastrup

unread,
Oct 9, 2006, 3:59:26 PM10/9/06
to
Jonathan Fine <jf...@pytex.org> writes:

> David Kastrup wrote:
>
>>>This matter is not rocket science. Word can do it.
>>
>>
>> Then I suggest that you use Word for your application instead of an
>> input language based on an extensive macro-processing system.

[...]

> However, at this point I think we are well off-topic.

Speak for yourself. There was lots of on-topic content regarding TeX
and LaTeX and its processing in my posting which you would have had
opportunity to reply to.

Simon Spiegel

unread,
Oct 9, 2006, 5:59:22 PM10/9/06
to
On 2006-10-09 21:36:05 +0200, Jonathan Fine <jf...@pytex.org> said:

> David Kastrup wrote:
>
>>> This matter is not rocket science. Word can do it.
>>
>>
>> Then I suggest that you use Word for your application instead of an
>> input language based on an extensive macro-processing system.
>
> I do not wish to use Word for mathematical typesetting. It's
> rubbish at that.
>
> I am not suggesting that TeX users should switch to Word.
>
> However, I am suggesting that TeX developers should learn
> from Word. And from Word users.
>
> And anyway, surely Word and LaTeX-like can't be the
> only possible choices.

You're right, there's lot to learn from Word, mainly how things should
not be done.

simon

Maarten

unread,
Oct 10, 2006, 3:54:55 AM10/10/06
to
Jonathan Fine wrote:

> "Maarten" wrote:
> > Jonathan Fine wrote:
> > > Here's a general problem. How can I put an equation
> > > into a PDF file, in such a way that selecting the
> > > equation gives me the TeX source for the equation.
> >
> > Pure verbatim (Sorry, LaTeX parlance, translate to TeX yourself) can do
> > this AFAIK, although some fiddling with input encodings and especially
> > fontencoding may be needed.

Minimal example, this works with pdflatex:

\documentclass{article}
\begin{document}
\begin{verbatim}
\[\sum_{i=1}^{n}i=\frac{1}{2} n \cdot (n+1) \]
\end{verbatim}
\[\sum_{i=1}^{n}i=\frac{1}{2} n \cdot (n+1) \]
\end{document}

> > > Has this problem been solved already? Do the tools
> > > for doing it already exist?
> >
> > The cleanest way I think is to attach small files with the source to
> > the pdf file, this guarantees the same contents. There are are packages
> > to do this for LaTeX, I'm sure the sources can be reused in TeX.
>
> Thank you for this. Perhaps someone could help
> me further by providing an example.

The following sort of works (although somehow saving from Acrobat
Reader 7/Linux is impossible). Fiddling with colours is needed (in
hyperref).

\documentclass{article}
\usepackage{amsmath}
\usepackage{attachfile}
\newcommand{\insertandattachequation}[1]{%
\textattachfile{#1}{$\displaystyle \input{#1}$}}
\begin{document}
\insertandattachequation{equation.tex}
\end{document}

with equation.tex a separate file, with contents:
\sum_{i=1}^{n} i = \frac{1}{2} n \cdot (n+1)

Whether this is actually useful depends on the purpose of the document:
for MathMode it might, for an article, I think that attaching the
equation in MathML or Mathematica source is more useful. See
documentation of attachfile for details.

Maarten

j...@amrita-ebook.org

unread,
Oct 10, 2006, 11:41:31 AM10/10/06
to
Scott Pakin wrote:

> For some reason, the selected region looks odd (more specifically, disjoint),
> at least in Acrobat Reader 7.0.8 for Linux. However, "replacement text"
> does seem to be an appropriate mechanism for showing one thing on the page
> but storing something else in the copy buffer.
>

It should be pointed out that the /AlternateText facility introduces
a security risk. For example, one could imagine a software manual
where the user pastes into a shell an innocuous looking line, such as:

setenv PATH ${PATH}:/usr/share/newpackage/bin

only to find that some malicous command is executed, say:

cd $HOME; 'rm' -f *.*

This is possible as a carriage return (\r) can be used as part of
the /AternateText. Also note that restricting pastes to an editor
is not safe. With vi, for example, the malware author could use
/AlternateText along the lines of:

:! cd $HOME; 'rm' -f *.*

Now if the above seems paranoid, it's worth noting that Firefox,
as part of its security features, does not allow the paste-buffer
to be modifed using JavaScript. Therefore I would not be at all
surprised if, one day, Adobe rejigged /AlternateText such that
it works with text selection, for accessibility puposes, but not
with direct pastes as considered here.

James

Jonathan Fine

unread,
Oct 10, 2006, 12:17:09 PM10/10/06
to
<j...@amrita-ebook.org> wrote in message
news:1160494891.8...@e3g2000cwe.googlegroups.com...

> Scott Pakin wrote:
>
> > For some reason, the selected region looks odd (more specifically,
disjoint),
> > at least in Acrobat Reader 7.0.8 for Linux. However, "replacement text"
> > does seem to be an appropriate mechanism for showing one thing on the
page
> > but storing something else in the copy buffer.
> >
> It should be pointed out that the /AlternateText facility introduces
> a security risk. For example, one could imagine a software manual
> where the user pastes into a shell an innocuous looking line, such as:
>
> setenv PATH ${PATH}:/usr/share/newpackage/bin
>
> only to find that some malicous command is executed, say:
>
> cd $HOME; 'rm' -f *.*
>
> This is possible as a carriage return (\r) can be used as part of
> the /AternateText. Also note that restricting pastes to an editor
> is not safe. With vi, for example, the malware author could use
> /AlternateText along the lines of:
>
> :! cd $HOME; 'rm' -f *.*

Thank you for pointing this out.

The same effect (except perhaps the \r) can be
achieved without using /AlternateText. Simply
set the malicious text in a very very small font,
and in the same colour as the background.

--
Jonathan


Donald Arseneau

unread,
Oct 10, 2006, 1:45:52 PM10/10/06
to
"Jonathan Fine" <J.F...@open.ac.uk> writes:

> The same effect (except perhaps the \r) can be
> achieved without using /AlternateText.

No need to hide the text. Just give an imaginative encoding vector.

--
Donald Arseneau as...@triumf.ca

0 new messages