# Minimal installation for TeX (pdflatex/pdftex)?

OP
OP

#### Spartrekus

##### Aspiring Daemon

Reaction score: 140
Messages: 924

No, really not by hand, never, please, use ` weave` and get the description of the pascal from the TeX sources, then you will understand what I am saying. The translation is not the source of bloat.

TeX is good, very good, no rewrite is necessary. But it would be nice if someone write an alternative, a new typography program, and the best would be to generate postscript directly.
Sounds the widest - but actually PS needs fonts.
Example:
</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>[1]

echo 'This is a test of Hello World \bye' > test.tex
pdftex --output-format=dvi test.tex
Output written on test.dvi (1 page, 244 bytes).

dvips test.dvi
' TeX output 2019.02.08:1849' -> test.ps
</usr/share/texlive/texmf-dist/dvips/base/tex.pro>
</usr/share/texlive/texmf-dist/dvips/base/texps.pro>.
</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>[1]

du -hs test.ps
28K test.ps

This PS file is quite large actually.

#### hruodr

##### Well-Known Member

Reaction score: 40
Messages: 306

You always need the fonts. A dvi file does not contain them and need them in external files, a ps file contain them and is hence bigger. You send the ps file to the printer with the fonts.

OP
OP

#### Spartrekus

##### Aspiring Daemon

Reaction score: 140
Messages: 924

No, really not by hand, never, please, use ` weave` and get the description of the pascal from the TeX sources, then you will understand what I am saying. The translation is not the source of bloat.

TeX is good, very good, no rewrite is necessary. But it would be nice if someone write an alternative, a new typography program, and the best would be to generate postscript directly.
A basic example seems to work actually.
PS file with font, and a simple example.

#### hruodr

##### Well-Known Member

Reaction score: 40
Messages: 306

Postscript is an elegant language, like forth, but it seems it is not comfortable enough to write everyday text like TeX. Perhaps this can be solved writing a "postscript editor" that helps writing everyday texts with postscript, helps drwaing with postscript and also helps learning postscript. Perhaps it can be done with Tcl/Tk?

OP
OP

#### Spartrekus

##### Aspiring Daemon

Reaction score: 140
Messages: 924

Postscript is an elegant language, like forth, but it seems it is not comfortable enough to write everyday text like TeX. Perhaps this can be solved writing a "postscript editor" that helps writing everyday texts with postscript, helps drwaing with postscript and also helps learning postscript. Perhaps it can be done with Tcl/Tk?
Just in C - it is easy to convert a Tex (basics \section(),...) to PS format.
C is fine for this - and it depends on nothing - just PS2PDF.

It works like this.
moveto starts from bottom : 10 is left
820 is the top.
top left : 10 820 moveto.

So it seems possible to understand it.

This will place at x=10 and 700 (almost on top of page)
20 is size of palatino.
/Palatino 20 selectfont
10 700 moveto
(This will show several lines. S20 )
show

show makes it appears on page
showpage "print" or display the page.

How to calculate the points between each lines ?
How to find out the character point size?

#### hruodr

##### Well-Known Member

Reaction score: 40
Messages: 306

to convert a Tex (basics \section(),...) to PS format.
No, the idea is not to make a TeX interpreter / compiler. Input is not TeX, but postscript plus some GUI actions to generate further editable postscript.

BTW: what you wrote above is not TeX, but something like LaTeX.

And you do not need PS2PDF for viewing or printing: postscript is enough.

OP
OP

#### Spartrekus

##### Aspiring Daemon

Reaction score: 140
Messages: 924

No, the idea is not to make a TeX interpreter / compiler. Input is not TeX, but postscript plus some GUI actions to generate further editable postscript.

BTW: what you wrote above is not TeX, but something like LaTeX.

And you do not need PS2PDF for viewing or printing: postscript is enough.
We maybe would like terminal

Markup:
text text
text
text.

C:
So it is easy to make hello world.
fopen( )
fgetc( )
detect linefeed or a given marker

PS:
int posx = 10; int posy = 820; //top left
position the cursor (PS) to 10 820 with moveto, and just bring on ( text text tex ) with '(' and ')' what the markup text document returns,
treat each char after another one:
if posx is greater than 800, add a linefeed, => posy -= size_pt ;

#### hruodr

##### Well-Known Member

Reaction score: 40
Messages: 306

We maybe would like terminal
Well, with TeX one writes on terminal with any text editor text that is to be seen on GUI. You cannot mess, you must give numbers (coordinates), you have no help from the computer to get the numbers (eg click here and see the numbers). To do a more or less trivial page layout with TeX is a lot of work.

Of course you can draw giving postscript commands, but the idea is to help the process of creating these commands with a GUI. You will in any case need a GUI or a printer to see the result.

OP
OP

#### Spartrekus

##### Aspiring Daemon

Reaction score: 140
Messages: 924

here a cool alternative to TeX:

Code:
``````%!PS

/Courier 10 selectfont
10 10 moveto
(HERE)
show

1 1 moveto
(-)
show

588 835 moveto
(-)
show

588 835 moveto
(|)
show

588 1 moveto
(|)
show

588 1 moveto
(-)
show

1 835 moveto
(-)
show
1 835 moveto
(|)
show
1 825 moveto
(L)
show

/Courier-Bold 10 selectfont

100 730 moveto
(1. Introduction Section)
show

/Courier 10 selectfont
100 710 moveto
(Location: X:100 Y:710)
show

100 700 moveto
(Hello This is the first line)
show

100 690 moveto
(Hello This is the 2. line)
show

100 680 moveto
(Hello This is the 2. line)
show

/Courier 10 selectfont
100 670 moveto
( )
show

/Courier-Bold 10 selectfont
100 660 moveto
(2. Second Section)
show

/Courier 10 selectfont
100 650 moveto
()
show

/Courier 10 selectfont
100 640 moveto
(Text Text Tex)
show

/Courier 10 selectfont
100 630 moveto
(Text Text Tex)
show

showpage``````
edit with nedit and create: test.ps

ps2pdf test.ps

mupdf test.pdf

0 0 to 588 835.
Ymax = 835 (top right of page)
Xmax = 588 (top right)

bottom left is 0 0

It goes upward !

10 is line space (10 pts).

Font Space:
Courier 10
In X direction: +6 will be the addtional space necessary
+ 10 is ok for Y direction.

#### hruodr

##### Well-Known Member

Reaction score: 40
Messages: 306

here a cool alternative to TeX:
Well, one must be very desesperated in order that this be an alternative to TeX.

But as you see, the "primitives" are just in postscript, it is not necessary to program them as in TeX and Metafont, but some construct above it is necessary. I would say, one can begin doing a prototype with Tcl/Tk, of course with C extensions, for example for text parsing.

OP
OP

#### Spartrekus

##### Aspiring Daemon

Reaction score: 140
Messages: 924

Well, one must be very desesperated in order that this be an alternative to TeX.

But as you see, the "primitives" are just in postscript, it is not necessary to program them as in TeX and Metafont, but some construct above it is necessary. I would say, one can begin doing a prototype with Tcl/Tk, of course with C extensions, for example for text parsing.
Just plain C is fair enough for a primitive first code.

Actually, the rendering of PS is awesome. Knuth got nice rendering because the fonts are already impressive. Courier looks strange, but palatino seems to be already implemented.

So, with nothing, it looks already very beautiful...

I just printed the output of the file.
It is actually kinda easier to make it in PS rather than TEX.

Are you ready to see the resulting C code (clang compilable)?

Let's call it : supertex.c ?

#### hruodr

##### Well-Known Member

Reaction score: 40
Messages: 306

Are you ready to see the resulting C code (clang compilable)?
I would propose to think about what the program must exactly do be before programming.

I have but a lot of work!!!

Knuth text looks better because he did care a lot on aesthetics. Just read in his TeXBook and his MFBook about it, their TeX-sources are in the TeX source, but perhaps you find them as PDF/dvi in the net (tricky to compile them). TeX and Metafont are real typesetting programs.

Perhaps an excersise: a C program that translates a mathematical formula written as in TeX to postscript.

OP
OP

#### Spartrekus

##### Aspiring Daemon

Reaction score: 140
Messages: 924

Done for a first approach !!

#### hruodr

##### Well-Known Member

Reaction score: 40
Messages: 306

Perhaps you can use Knuths algorithms, translate some to C. Knuth would be perhaps very happy if you read, learn and experiment with his code. Just read about the license:

OP
OP

#### Spartrekus

##### Aspiring Daemon

Reaction score: 140
Messages: 924

You can give a try.

There is a makefile.

Here it is - about less than 100 lines for making a first prototype.
It does only Y direction so far.

I want C because I can compile it on any kind of hardware (solaris, amiga, commodore, bsd,....).

#### shkhln

##### Well-Known Member

Reaction score: 171
Messages: 464

Perhaps you can use Knuths algorithms, translate some to C.
Are you trying to outdo Spartrekus at his own game? Any person capable of uploading almost 600 GitHub repos without touching git is not a person to be f###### with.

OP
OP

#### Spartrekus

##### Aspiring Daemon

Reaction score: 140
Messages: 924

Are you trying to outdo Spartrekus at his own game? Any person capable of uploading almost 600 GitHub repos without using git is not a person to be f###### with.
I do not need to install git. How much disk space will it require to install git ?
Github is anyhow in the hands of Microsoft.
// Subversion is a good alternative.

Note:
This is only for scientific interests - research in digital programming maybe.

So,... first prototype:
mission accomplished
X will be done later.... just Y for first test.
What to do next with this PS format?

A dummy text document was converted to PS and later to PDF.
In order to convert this document, only any kind of C compiler can be used to make stex.
stex will process the text document and it will create the PS document.
I tested, and this PS document is printed with just : lpr

lpr -PPRIINTER -o fit-to-page -o media=A4 "dummy.ps"

#### hruodr

##### Well-Known Member

Reaction score: 40
Messages: 306

Are you trying to outdo @Spartrekus at his own game?
Spartrekus learns by doing, by trial and err, not by first studying. If he get things uploaded and reachs his only goal in the matter: what is the problem of uploading in the "false" way?

He does not read first the whole description of postscript, but begin doing examples. It is his way.

But yes, I was trying to show him other approach: to first study. To read what Knuth wrote and was written to be read by people learning. To first build a concept and then program.

But in any case: his approach of learning is not absolutely false and my approach, as also may be yours, not absolutely correct. A good balanced mixture is a better approach.

#### shkhln

##### Well-Known Member

Reaction score: 171
Messages: 464

Nothing really, it's just that uploading files via browser ui is the most cumbersome and labor intensive method available, which makes 600 repos achievement more impressive. I feel successfully trolled even thinking about it.

#### hruodr

##### Well-Known Member

Reaction score: 40
Messages: 306

Here it is - about less than 100 lines for making a first prototype.
Too much lines. With tcl would be perhaps 3 lines. And TeX does much more: align lines, breaks on the right place, adds "glue" to make length of lines flexible. Just see in TexBook what it does. Also the input of formulae.

Just try to write a function `char *fortran(char *frm)` that takes a formula like in TeX input and gives postscript code.

#### ralphbsz

##### Daemon

Reaction score: 1,017
Messages: 1,638

Did he write it with fp (fp-ide) turbo pascal originally?
That is a completely ridiculous notion. Sorry, but Don Knuth does not use turbo pascal. Don uses real computers. Turbo Pascal runs on crappy toys.

The first version of TeX was written in SAIL, the famous language used by the DEC-10 (a mainframe made by Digital Equipment in the 60s and 70s). The language was designed for implementing artificial intelligence applications at Stanford (thence the name). The next version was written in "literate programming": The source code is written in a language called Web (it has nothing to do with the world-wide web, and predated it by about 20 years). You can take the Web source code and run it through either of two programs, one called "tangle", the other called "weave":
• The output of one of them is TeX code, which you can run through TeX, and it produces the full documentation for the source code. The documentation is so beautiful and clear, it reads like a book. Matter-of-fact, the source code was published in book form (I think it is roughly half a dozen volumes for TeX and MetaFont).
• The output of the other program is Pascal source code (in a strange dialect of Pascal which is specific to Knuth), and which you can compile into the TeX executable. Since the original Pascal compiler for the DEC-10 doesn't exist any longer, it is today typically converted into C code.
The other thing one has to remember that TeX is really not a document description language. It is actually a full programming language. Don Knuth is not a programmer, he is a computer scientist (and one of the greatest ones). You can actually implement a BASIC interpreter in TeX if you want (it's been done). The thing about TeX is: while it is a full programming language, it happens to be designed to produce DVI output as a side effect, so it happens to be most useful (and most easy to use) to write documents.

TeX itself is amazingly stable; it has had very few changes in the last dozen years or so. Its version number is asymptotically approaching pi.

In practice, raw TeX is an somewhat inefficient way to write documents. That's why people use LaTeX instead. LaTeX is implemented in TeX (it is nothing but a macro package for TeX). The huge difference is that TeX is a typesetting language: intellectually it thinks about "put this glyph here on the page", or "lay out the characters on this line while keeping sentences together but have nice line breacks". In contrast, LaTeX is a markup language (like SGML and HTML): intellectually it thinks about "this is a heading, and this is the caption under a figure". For large documents, LaTeX is much easier to use. Because LaTeX is nothing but a macro package for TeX, you have the whole power of TeX available, in addition to the document structuring mechanisms. LaTeX is the product of another computer science genius, Leslie Lamport (of Paxos fame). Obviously, Don and Leslie are friends, and live close to each other (Don is a professor at Stanford in Palo Alto, and Leslie worked for a long time a Digital Research in Palo Alto, and I think he now works at Microsoft in Mountain View or Sunnyvale).

To a large extent, TeX (and LaTeX) have nothing to do with postscript and PDF. They generate DVI output, which is device independent (thence the name). That output is then merged with fonts (which are often created by Knuth's program MetaFont, although people often use inferior Postscript fonts), to create device-specific output. The DVI format is relatively simple, and a DVI driver can be pretty short. I happen to know that the DVI driver for an early laser printer was written in 6 or 7 lines of APL ... but the lines were about 300 characters long (and APL source code is amazingly dense and bizarre, de-facto unreadable). I started using TeX in about 1982 (on an IBM mainframe, where for previewing we used Tektronix 4014 graphics terminals, and we had a wet toner-based electrostatic Versatec plotter for output). Today, most output from TeX goes into postscript or PDF format, but the original dvips driver (written by my former colleague Tom Rokicki from HP Labs) is small and efficient, and I'm sure you can find the source code for it on the web.

I'm sure a minimal TeX / LaTeX / MetaFond / dvips distribution could be built from original sources, and stored in a very small amount of space (dozens or hundreds of megabytes, mostly for the fonts). It would be an interesting exercise in retrocomputing. Would probably take a real expert a week or two to do; configuring and setting it up is famously difficult. Generating the fonts with mf takes considerable CPU time (we used to run the font generation overnight, when computers were still measured in single-digit MIPS).

Little personal story: One time I was at a meeting, sitting next to Leslie Lamport. He was crying. Don Knuth was also there, and he was also crying. So was I. Matter-of-fact, everyone in the room was crying. It was the memorial service for a colleague of ours, and the widow of our colleague was giving the eulogy on stage (she is a well-known computer science prof at Harvard herself). Very sad.

#### hruodr

##### Well-Known Member

Reaction score: 40
Messages: 306

Don Knuth is not a programmer, he is a computer scientist (and one of the greatest ones).
No, no, no!!!! He is a mathematician.

#### olli@

##### Well-Known Member
Developer

Reaction score: 277
Messages: 315

No, no, no!!!! He is a mathematician.
Please excuse me for being blunt, but that's a completely clueless statement. It's not even funny.

I have Knuth's famous TAOCP volumes on my book shelf right beside me, and I use them a lot. I invite you to look up TAOCP on Wikipedia. Maybe even go to a library and look at the books yourself, and read one of the chapters. I'm pretty sure that you won't deny anymore that Knuth is a computer scientist. (Of course, every computer scientist is also a mathematician to some degree, but that doesn't change the point.)

#### hruodr

##### Well-Known Member

Reaction score: 40
Messages: 306

I invite you to look up TAOCP on Wikipedia.
Do you really think that I do not know Knuths "The Art of Computing Programming"? If you read it carefully, you note that Knuth is not a computer scientist, but a mathematician.

Well, you can say he is a computer scientist due to the way he computes the splines in Metafont using formula 10 of the Article linked below. I am sure that the splines may be calculated much better, but I suppose that was a compromise to have a working TeX implementation faster and not because he was playing computer scientist.

Article: http://i.stanford.edu/pub/cstr/reports/cs/tr/85/1047/CS-TR-85-1047.pdf

#### rigoletto@

##### Daemon
Developer

Reaction score: 892
Messages: 1,853

Miktex runs on about 150 mb
I have MiKTex installed (also SEE) with less than a third of that and you can still make it smaller if you really want to, its all depends on how you build it.
MiKTex bring many builtin UI (Qt5) stuff (like Texworks, a console UI, etc.) you can disable at build time.