16

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.

6
  • 4
    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. Commented Jan 9, 2013 at 16:43
  • 4
    Welcome to TeX.sx! Commented Jan 9, 2013 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 Commented Jan 9, 2013 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
    Commented Jan 9, 2013 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. Commented Jan 9, 2013 at 18:23

2 Answers 2

40

Adding

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

% extra lines for 2019 latex release
\let\newmarks\relax

\let\acute\relax
\let\grave\relax
\let\ddot\relax
\let\tilde\relax
\let\bar\relax
\let\breve\relax
\let\check\relax
\let\hat\relax
\let\vec\relax
\let\dot\relax
\let\widetilde\relax
\let\widehat\relax

% end of addition

\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
\let\newmarks\relax

\let\acute\relax
\let\grave\relax
\let\ddot\relax
\let\tilde\relax
\let\bar\relax
\let\breve\relax
\let\check\relax
\let\hat\relax
\let\vec\relax
\let\dot\relax
\let\widetilde\relax
\let\widehat\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{[email protected]}}

% 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}
21
  • 3
    WOW! Could you just please elaborate why the first 5 lines are necessary?
    – yo'
    Commented Jan 9, 2013 at 16:55
  • 8
    @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. Commented Jan 9, 2013 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
    Commented Jan 10, 2013 at 11:54
  • 2
    @DavidCarlisle: But the document is actually a LaTeX document. Please try this (adding the six lines) with texbook.tex :-) Commented Jan 10, 2013 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. Commented Jan 10, 2013 at 12:49
9

»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.

3
  • 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
    Commented Jan 9, 2013 at 18:16
  • 6
    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
    Commented Jan 9, 2013 at 18:18
  • Obviously there is a „solution“ to the problem you mentioned. See the other answer. This still leaves the superviser with a document he does not understand.
    – Keinstein
    Commented Feb 25, 2022 at 18:15

You must log in to answer this question.

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