[Tex/LaTex] Hello World in pdfLaTeX


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.

\usepackage[scaled =.92]{helvet}
\lhead{Sound and TeX}\chead{}
\rhead{Can you hear me?}
pdftitle={Hello world},pdfsubject={Invest your new year improving your TeX skills}%

function Hello()
  var cSpeaker = tts.getNthSpeakerName(0);
   tts.speaker = cSpeaker;
   tts.qText ("Hello, Tex Stack Exchange. Helloooo, can anybody hear me? Helloooo?");

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.");

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?");

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");


%% This must be here

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

%% Define the heading

\textbf{\Huge Hello World!\\[0.2cm] Can you hear me?}

%% Push button is defined here
onclick={HelloWorld();}, bordercolor={0.650 .790 .94}%
]{Hello World!} 

onclick={WhatsUp();}, bordercolor={0.650 .790 .94}%
]{What's Up?} 

onclick={Universe();}, bordercolor={0.650 .790 .94}%
]{What's with the Universe?} 
\heading{Press a button!}\\


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

Best Answer

When asking such questions, it is helpful to consider whether they pass the laugh test: http://river-valley.zeeba.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.