Converting from one file type to another
Sometimes you can do this simply by opening the file in the appropriate program (e.g. libreoffice, The GIMP) and using Save As to save it in a different format.
How do I convert a document from...
- ps to pdf
- pdf to ps
- Word to pdf
- txt to tex
- tex/latex to html
- tex/latex to pdf
- .dvi to .ps
- .ps to ascii text
- .ps to various formats eg .fig
- .dvi to plain text
- .dvi to .pdf
- dos to unix (or how to remove the ^M characters in a file)
- How do I convert a document from ps to pdf
To convert a document from ps to pdf useps2pdf
. - How do I convert a document from pdf to ps
To convert a document from pdf to ps usepdf2ps
. Syntax is pdf2ps input.pdf output.ps - How do I convert a document from Word to PDF
Adobe Acrobat Pro (Windows) or Libreoffice (Linux). - How do I convert a document from txt to tex
To make a plain text file into a valid LaTeX document, add\documentclass{article} \begin{document}
to the beginning, and
\end{document}
to the end. You can also use
\section*{Heading 1}
and\subsection*{Heading 2}
to add headers. The Computing Service run a training course on LaTeX. - How do I convert a document from tex/latex to html
Use latex2html. Typelatex2html file.tex
or see the man pages for more options. - How do I convert a document from tex/latex to pdf
To convert TeX/LaTeX directly to PDF,pdflatex file.tex
(produces file.pdf). Alternatively or if the file has pictures/figures in it, the below will work so long as the figures are of type eps (encapsulated postscript) since those are the only kind that dvips will really cope with. However .gif/.jpg files can usually be converted to .eps fairly easily with gimp.If you have a latex document called fred.tex then a recipe which works would be:
# Run latex on it latex fred.tex # 2nd, 3rd time if there are forward references which need to be right latex fred.tex latex fred.tex # Convert to postscript. -t specifies the paper type (not needed # normally, but otherwise the ps2pdf will guess letter size), -Ppdf # sets things up for conversion to pdf, -o says where the output will # go (a file in this case). dvips -t a4 -Ppdf -o fred.ps fred.dvi # Convert postscript to pdf ps2pdf fred.ps fred.pdf This should result in a .pdf file fred.pdf
- How do I convert a .dvi file to a .ps file
dvips -o filename.ps filename.dvi
This will produce filename.ps from filename.dvi. The .dvi part is optional. ie
dvips -o filename.ps filename
will work just as well.
- How do I convert a .ps file to a ascii text
Use the command ps2ascii which will give you a text-only version of the ps file ie ps2ascii file.ps will output the ascii text on the screen, while ps2ascii file.ps file will save the output to a file called file.
Use ps2ascii --help for more options. - How do I convert a .ps file to other vector formats eg graphical for further processing
Use the command pstoedit. Example usage to convert a .ps file called house.ps to a .fig file ispstoedit -f fig house.ps house.fig
The pstoedit website contains a complete list of supported formats.
- How do I convert my .dvi file to text
First use dvips to convert the file to postscript, then use ps2ascii to convert the postscript to ascii text. You will lose the pictures and other graphics, but maintain the text of the document. This is sometimes useful if you accidentally delete the .tex file. ie to get the ascii from myfile.dvi into a file called myfiledvips -o myfile.ps myfile.dvi ps2ascii myfile.ps myfile
- How do I convert a document from .dvi format to .pdf
Use dvipdf.
But sometimes this produces a file in which the superscripts do not look right in acroread. Often when you magnify the file in acroread, the superscripts look correct, as they do when using xpdf to view the resultant .pdf file.
A way to overcome this problem is to convert the .tex code directly to pdf with pdflatex or pdftex. - dos to unix (or how to remove the ^M characters in a file)
dos2unix is a very simple script which converts from DOS or Mac text formats to unix (the name is historical).
usage is
dos2unix file
it replaces your file with the converted version. To keep the old file you could use
dos2unix -n file newfile
.It also removes Ctrl-Z which occurs at the end of some DOS files.
You can go the other way with
unix2dos
.