Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

After many years being silent, TeX can now talk! Almost minimal code below! It should be of particular interest to Physicists and Cosmologists. Need to have Adobe Reader installed.

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[scaled =.92]{helvet}
\setlength{\paperwidth}{5.2075in}
\setlength{\paperheight}{4.90in}
\renewcommand*{\familydefault}{phv}
\usepackage[pdftex,margin=0.5in]{geometry}
\usepackage{soul}
\usepackage{fancyhdr}
\lhead{Sound and TeX}\chead{}
\rhead{Can you hear me?}
\lfoot{}\cfoot{}\rfoot{}
\pagestyle{fancy}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage[pdftex,pdfpagelayout=SinglePage,
pdftitle={Hello world},pdfsubject={Invest your new year improving your TeX skills}%
]{hyperref}
\definecolor{background}{rgb}{0.99,0.98,0.90}
\pagecolor{background}
\setlength{\parindent}{0.0cm}
\usepackage[pdftex]{insdljs}

\begin{insDLJS}[test]{test}{JavaScript}
function Hello()
{
  var cSpeaker = tts.getNthSpeakerName(0);
   tts.speaker = cSpeaker;
   tts.qText ("Hello, Tex Stack Exchange. Helloooo, can anybody hear me? Helloooo?");
   tts.talk();
}


function HelloWorld()
{
  var cSpeaker = tts.getNthSpeakerName(0);
   tts.speaker = cSpeaker;
   tts.qText ("Hello, Tex Stack Exchange. Helloooo, can anybody hear me?");
   tts.qText("This is a new and alien TeX world.");
   tts.talk();
}

function WhatsUp()
{
  var cSpeaker = tts.getNthSpeakerName(0);
   tts.speaker = cSpeaker;
   tts.qText ("Humans are not proud of their ancestors, and rarely invite them round to dinner.");
   tts.qText("What\'s up?");
   tts.talk();
}

function Universe()
{
  var cSpeaker = tts.getNthSpeakerName(0);
   tts.speaker = cSpeaker;
   tts.qText ("In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.In those days spirits were brave, the stakes were high, men were real men, women were real women and small furry creatures from Alpha Centauri were real small furry creatures from Alpha Centauri. There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable. There is another theory which states that this has already happened. I am Douglas Adams");
   tts.qText("Who are you? I may be a sorry case, but I don't write jokes in base 13");
   tts.talk();
}


\end{insDLJS}

%% This must be here
\OpenAction{/S/JavaScript/JS(Hello();)}

%% Short hand commands
\newcommand{\textforlabel}[2]{%
\TextField[name={#1}, value={#2}, width=9em,align=2,%
    bordercolor={0.990 .980 .85},%
 readonly=true]{}%
}


%% Define the heading
\newcommand{\heading}[1]{\so{#1}}

\begin{document}
\phantom{0}
\begin{center}
\vspace{2cm}
\textbf{\Huge Hello World!\\[0.2cm] Can you hear me?}
\end{center}
\vfill
\newpage

\begin{Form}
\begin{center}
%% Push button is defined here
\PushButton[name=hello,%
onclick={HelloWorld();}, bordercolor={0.650 .790 .94}%
]{Hello World!} 
\\[10pt]

\PushButton[name=hello,%
onclick={WhatsUp();}, bordercolor={0.650 .790 .94}%
]{What's Up?} 
\\[10pt]

\PushButton[name=hello,%
onclick={Universe();}, bordercolor={0.650 .790 .94}%
]{What's with the Universe?} 
\\[2cm]
\heading{Press a button!}\\
\end{center}
\end{Form}


\end{document}

On a more serious note, does (all)TeX have a place in the "new" media?

share|improve this question
    
Not that I want to spoil the fun, but what exactly is the question here? –  Caramdir Jan 13 '11 at 23:10
    
@Caramdir The question is at the bottom. We see more and more 'multi-media' in documents, print is being used less and less. Is TeX/LaTeX going to be part of all these? –  Yiannis Lazarides Jan 13 '11 at 23:16
    
Is TeX/LaTeX only about printing? –  YuppieNetworking Jan 14 '11 at 2:30
2  
@Yiannis: There are packages to typeset music. What about adjoining to these the possibility of playing the music that is typeset? –  Bruno Le Floch Jan 14 '11 at 12:46
    
@Bruno Le Floch: TeX itself typesets text, so should it also be a text-to-speech reader? External utilities do that, as they should. I would think that score-to-music is significantly easier, since the notation is totally unambiguous and highly structured, so can't the same (or similar) utilities do this as well? –  Ryan Reich Jan 14 '11 at 13:24
show 2 more comments

1 Answer

up vote 12 down vote accepted

When asking such questions, it is helpful to consider whether they pass the laugh test: http://river-valley.tv/tug-2010/an-earthshaking-announcement.

More seriously, I think TeX is, by definition, a typesetting system. It happens to have a powerful programming capability which has allowed that particular facility to be expanded to its logical limit, so that we can draw quite elaborate pictures using only TeX code. It also happens to have been expanded to produce PDF documents, which (presumably through the initiative of Adobe) have come to encompass a lot of media which are not necessarily printed. I believe (or at least I hear, as I am not sure I believe) that we can also deal with movies in a TeX document. The question seems to be, then, whether TeX should actually be considered a PDF creator in the most general sense that it can deal with all provisions of the PDF standard (whatever that is).

I think this is a much greater and more ambitious expansion of the domain of TeX than simply to push the boundaries of its programming abilities. Suppose, for example, that Javascript is deemed to be an acceptable output; what is the time (in minutes) that would then elapse before someone wants this Javascript to interact with the document structure? Must TeX handle that? Must TeX become a Javascript interpreter? If in the future documents come to be delivered through interactive movies, must TeX create those movies? I say it should not.

TeX is designed to solve a single problem: setting letters into words into lines into paragraphs into pages, interspersed with mathematics and with displays or inserts of various kinds. To facilitate the automation of this task in a variety of unanticipated circumstances, it provides a complete (if obtuse) programming language with many hooks into the typesetting functions with which it operates. The fact that this language is Turing-complete leads enthusiastic people to claim that TeX can do anything, but this is not true: the task in question must be capable of description in this language. By virtue of the hooks, those tasks include typesetting, but the only facilities provided for other tasks are: the \special command and the very limited input/output commands (particularly \write18). Effectively, TeX allows other kinds of programming applications only through the wholesale importation of external utilities.

I think it's a mistake to try to make TeX do more than it is designed to be easily capable of doing, and a mistake to try to insert new features into that design. For example, hyperref works because one can use \special simply to feed information to the viewer, but it would be silly to try to use some kind of Javascript program to rewrite the document in accordance with a hyperlink. The reason is that TeX thinks of a document as being a finished product, and so "runtime" operations are not even considered. This is necessary for the problem of typesetting ever to be solved. Of course, if your Javascript has no runtime effect on the document it can be embedded via \special, but since that is already possible I doubt it is the question. Whether it is a matter of practicality or of good taste...my opinion was already given in the first sentence.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.