13

I want to know if I can compile raw TeX code with the texi2pdf program.

2
  • 1
    Did you mean to ask about the difference between Plain TeX and texinfo?
    – jarnowicz
    Commented Oct 24, 2016 at 20:07
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. A suggestion: Do us a favour and change your username to something more telling than "user1234". Commented Oct 24, 2016 at 20:34

3 Answers 3

15

Texinfo is yet another macro package which defines its own markup language, which may be processed by TeX to produce dvi (texi2dvi) or pdf (texi2pdf). You may include arbitrary (roughly, plain) TeX code inside the @iftex and @end iftex commands; but then, anything within this conditional will be ignored in conversion to other formats (html, info, etc.). texi2[dvi|pdf] are shell scripts that automate the processing of Texinfo files to produce documentation for printing, analogous to makeinfo, a program which processes the same documentation to produce online documentation in info or html formats, for instance.

texi2pdf may also process automatically LaTeX files, by checking the filename extension. Thus, texi2pdf filename.tex automatically processes filename.tex as a LaTeX file, with its main byproducts (bibtex and makeindex).

You may trick texi2pdf into processing Plain TeX files with the strategies suggested by Fran; but then you would be only forcing the texi2pdf script to use the pdftex engine with the pdftex format on the Plain TeX file, and the result would be the same as using the command pdftex filename.tex.

0
8

Your question is not terribly clear. As I understand it, you are asking whether you can compile raw .tex code using texi2pdf without installing a TeX distribution.

The answer to that question is that you cannot because texi2pdf just acts as a wrapper which depends on the availability of compilation commands provided by a TeX distribution.

Note that my reason for interpreting your question in this way, rather than the way everyone else is interpreting it, is that I cannot currently imagine any other motivation for it. That is, if you have a TeX distribution installed, you might just as soon use pdftex or pdflatex to compile a .tex file: the only reason to use the wrappers provided by texinfo is that you are dealing with a .texi file rather than a .tex one.

So while it is presumably possible to use texi2pdf to compile .tex files, it is hard to see why anybody would do that.

The base wrapper is texi2dvi. texi2pdf is a shorthand enabling the use of the pdfTeX engine in place of the standard TeX one.

Running texi2dvi on a .texi file is equivalent to the following 5 steps, according to the documentation:

  1. Run 'tex' on your Texinfo file. This generates a DVI file (with undefined cross-references and no indices), and the raw index files (with two letter extensions).

  2. Run 'texindex' on the raw index files. This creates the corresponding sorted index files (with three letter extensions).

  3. Run 'tex' again on your Texinfo file. This regenerates the DVI file, this time with indices and defined cross-references, but with page numbers for the cross-references from the previous run, generally incorrect.

  4. Sort the indices again, with 'texindex'.

  5. Run 'tex' one last time. This time the correct page numbers are written for the cross-references.

Steps 1, 3 and 5 require at least a minimal installation of TeX to be available. (If you are dealing with a .tex file, I assume steps 2 and 4 don't apply.)

9
  • The OP might also be looking for a way to automate the 'repeatedly run TeX and ancillary programs until the cross-references converge' process.
    – zwol
    Commented Oct 25, 2016 at 14:31
  • using texi2pdf filename.tex and setting (PDF)LATEX=(pdf)tex are documented. Indeed, using texi2dvi|pdf to process automatically latex, bibtex and makeindex files is supported. It is all in the info manual. So using texi2dvi for (La)TeX files is not violent at all; it might even be convenient.
    – jarnowicz
    Commented Oct 25, 2016 at 16:27
  • @zwol True. There are more straightforward ways to do that, though.
    – cfr
    Commented Oct 25, 2016 at 21:47
  • 1
    @wicho I didn't suggest it was violent. I think it doesn't make sense to do it because there are simpler options for automation which will also deal with many features not supported by texinfo.
    – cfr
    Commented Oct 25, 2016 at 21:52
  • Insightful answer to a very vague question. Commented Oct 26, 2016 at 0:14
7

According to man texi2pdf to process (e)plain TeX files, one must set the environment variable LATEX=tex. This is true for the DVI ouput with texi2dvi or texi2pdf --dvi, to use the etex engine instead of latex, but for a PDF output the setting really should be PDFLATEX=pdftex to change the pdflatex engine by pdftex. Thus, in a Linux system with a plain TeX file as test.tex, the procedure could be:

$ PDFLATEX=pdftex ; export PDFLATEX ; texi2pdf test.tex

Or alternatively, inform to the program that the source code is a TeXinfo file, in spite of the .tex extension:

$ texi2pdf --language=texinfo test.tex 

Or more tricky, change the extension. Not necessarily must be that of the texinfo files (.texi) since names without .tex, not being recognized as LaTeX files, will be treated as texinfo files, in spite of any other suffix (or even if there are not any suffix). So you can name it, for instance, test.foo.

In Linux, one can use hard links to maintain several names for the same file, so you can maintain the original file name test.tex but use test.foo to be compiled with texi2pdf:

$ ln test.tex test.foo
$ texi2pdf  test.foo 

As explained in another answer, deceiving the program in this way work since TeXinfo files are based in plain TeX, and thus using the same engines, but you run the risk of deceiving yourself with a misleading or non standard suffix.

3
  • @erreka Yes, as I said, setting the environment variable to tex failed, i.e., still run pdflatex, not pdftex, but the plain TeX passed as a texinfo file run pdftex, so really this is not needed at all, as far I can see.
    – Fran
    Commented Oct 24, 2016 at 19:48
  • @erreka Is the typical cryptic advice of man page, that is the same for two programs, so it take some time to figure what really mean. :( In a pure Linux also work set PDFLATEX instead of LATEX.
    – Fran
    Commented Oct 24, 2016 at 20:16
  • @wicho I really mean: Use the extension [whatever you like, except .tex]. I edited the answer to clarify. The .info was simply the first non .tex and .texi suffix that came to my mind. It is hard today find not "reserved" extensions.
    – Fran
    Commented Oct 25, 2016 at 18:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .