14

I was asked to convert a file from LaTeX format to TeX format, so it could be compiled by TeX. I use LaTeX a lot, but I'm quite unfamiliar with TeX. And the file is pretty long. So I was wondering if there's software or trick could simplify a bit the task.

BTW, I haven't installed TeX on my Ubuntu machine because I think I can use pdftex to test if the file is compatible with TeX. Am I right?


Edit:

The reason that I need to do this is that my supervisor asked me to convert something that I wrote with LaTeX into TeX style because he only knows how to use TeX. So the file should not only be compiled by TeX, but the grammar should also be TeX style so my supervisor could understand and modify it.

  • 3
    LaTeX is written in TeX so you can (with a bit of effort) just simply \input latex.ltx at the start of your file and then process it with tex, but it is rather pointless, it just makes the input longer and the processing slower. – David Carlisle Jan 9 '13 at 16:43
  • 4
    Welcome to TeX.sx! – Andrew Swann Jan 9 '13 at 16:56
  • 8
    Your supervisor should know that plain tex is an example format called "basic macros" in the TeXBook and not intended for document production. It simply has no mechanisms for font handling or cross referencing or anything that you actually need in a modern document. Of course you can define them and people do which is fine, but inputting your own macros to define those things and inputting the latex sources are not really any different conceptually, and the latex sources have been tested rather more over the last 30 years or so – David Carlisle Jan 9 '13 at 17:47
  • 2
    As David says, plain TeX has very much more limited mechanisms than LaTeX. Your supervisor will have his/her own approach to these requirements, and it's simply not possible to automatically convert from LaTeX to what a plain TeX user feels is the 'correct' way (each plain user will be different). – Joseph Wright Jan 9 '13 at 17:56
  • 8
    ask your supervisor for a typical file of his to use as a model. it will almost certainly input some macro files -- perhaps eplain or amstex or manmac, to name several that have been used relatively widely in the past (and are still used by some old-timers). reasonable user documentation is available for at least the first two. also, what field is this in? with that information, you should be able to ask questions that would get more reasonable answers. even so, don't expect this to be a walk in the park. – barbara beeton Jan 9 '13 at 18:23
39

Adding

\def\patterns#1{}
\catcode`\{=12
\let\newtoks\relax
\let\dump\relax
\let\+\relax
\let\newinsert\relax
\input latex.ltx

To a LaTeX file makes it a plain TeX file.

This is a LaTeX answer I gave to a question earlier today which runs without error in pdftex as modified:

\def\patterns#1{}
\catcode`\{=12
\let\newtoks\relax
\let\dump\relax
\let\+\relax
\let\newinsert\relax
\input latex.ltx
\documentclass[a4paper]{IEEEtran}

%\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lipsum,tabularx}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Here, main documents begins %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\title{FooBar}
\author{Bar Foo,~\IEEEmembership{foobar@google.com}}

% The paper headers
\markboth{FooBar 2013}%
{FooBar2013}

% make the title area
\maketitle

%% -----------------
%% |   Main part   |
%% -----------------

\lipsum

\section{aaa}
\noindent
\begin{tabularx}{\linewidth}{@{} r X @{}}
    Step 1: & \lipsum[1] \\
    Step 2: & \lipsum[2] \\
    Step 3 ggggggg kk kk jj gg : & \lipsum[3] \\
\end{tabularx}

\makeatletter
\renewcommand*\@IEEEiedmakelabel[1]{\hspace\labelsep
                                \parbox[t][0pt][t]{\itemindent}{\raggedright\normalfont\bfseries #1}}
\makeatother
\section{bbb}

\begin{description}

\item[Step 1]
 \lipsum[1]
\item[Step 2]
\lipsum[2]
\item[Step 3 ggggggg kk kk jj gg ]
\lipsum[3]
\end{description}


\makeatletter
\renewcommand*\@IEEEiedmakelabel[1]{\hspace\labelsep
                                \makebox[\linewidth][l]{{\normalfont\bfseries #1}}}
\makeatother
\section{bbb}

\begin{description}

\item[Step 1]
 \lipsum[1]
\item[Step 2]
\lipsum[2]
\item[Step 3 ggggggg kk kk jj gg ]
\lipsum[3]
\end{description}


\end{document}
  • 2
    WOW! Could you just please elaborate why the first 5 lines are necessary? – yo' Jan 9 '13 at 16:55
  • 7
    @tohecz you need to clobber \patterns as that sets up hyphenation and is only allowed in initex runs not typestting runs (just use the hyphenation in plain tex) \dump is similar (that dumps a format but is an error if executed in plain tex) the catcode of { is set back because latex explicitly tests that someone is doing this and gives an error message (as normally inputting latex.ltx into plain tex is a mistake) and the remaining ones are because \outer is a pointless irritant. – David Carlisle Jan 9 '13 at 17:00
  • 2
    Instead of using the pre-generated latex.fmt, you include the whole latex source at the beginning of the document, so it is no surprise it compiles with pdftex, but I think this is not the spirit of the question, since the syntax used in all document except the first six lines, is latex syntax (i.e: \begin/\end environments, font changing commands, sectioning commands, etc.) – JLDiaz Jan 10 '13 at 11:54
  • 2
    @DavidCarlisle: But the document is actually a LaTeX document. Please try this (adding the six lines) with texbook.tex :-) – Martin Schröder Jan 10 '13 at 12:15
  • 3
    @MartinSchröder There is no difference in principle between this and texbook.tex both input macros (latex.ltx and manmac.tex respectively) and use some markup defined by those macros. As I comment above the macros you input determine the markup used, that is always the case with "plain TeX" files as plain itself has so little document level markup defined. Obviously if you input manmac before this document or latex.ltx before texbook you will get error. You appear to be saying that any document that defines a macro is no longer "plain tex" I do not accept that. – David Carlisle Jan 10 '13 at 12:49
7

»So the file should not only be compiled by TeX, but the grammar should also be TeX style so my supervisor could understand and modify it.«

I'd be very surprised to see a full solution to this problem. One thing is that TeX can compile a file, but it is a completely other thing to convert LaTeX into readable TeX, which can be handled, revised, changed, amended, in short: be a basis for further writing.

Just as an example: 

The line \documentclass[pagesize, parskip=half, headings=big, english, DIV=calc, BCOR=5mm]{scrartcl} contains quite a lot of instructions. How in the world transfer this into plain TeX except including more or less the whole KOMA-script bundle into the file?

Maybe you tell us a bit more about your file and the intentions of your supervisor.

  • 2
    This looks like a comment. Would you like to change it into a comment, or do you plan to extend it to a real answer? – Stefan Kottwitz Jan 9 '13 at 18:16
  • 3
    This is no comment. This is an answer: what the OP would like to do, seems not possible, unfortunately. And to elaborate on the reasons for that, including an example, is not very readable in a comments field, besides that. – Keks Dose Jan 9 '13 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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