Conversion ToolsLaTeX to PDF

Information and discussion about output converters related to LaTeX (e.g. dvips, ps2pdf, ...)
Post Reply
simo
Posts: 18
Joined: Thu Feb 04, 2010 4:27 pm

LaTeX to PDF

Post by simo »

I have figured out some way to convert .tex files to pdf using a batch file but it has some issues. like depositing .dvi files to the miktex root folder. I need help to do this better. Remember am using a batch file, I will post the cmds.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

LaTeX to PDF

Post by gmedina »

Hi,
simo wrote:I have figured out some way to convert .tex files to pdf using a batch file but it has some issues. like depositing .dvi files to the miktex root folder. I need help to do this better. Remember am using a batch file, I will post the cmds.
We're waiting for the announced code. I surely won't be able to help you with this particular issue, but perhaps some other member will.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
simo
Posts: 18
Joined: Thu Feb 04, 2010 4:27 pm

LaTeX to PDF

Post by simo »

*****This is the first batch file for the first step which compiles .tex *****to .dvi*****
*****Note:***
*****1. the cmds 1st directs to the folder containing your .tex file*****
*****2. the file is compiled twice for clarity*****
***** I have named it compiler1.bat***

Code: Select all


cd\
J:
cd Simo Project
cd coding5th
cmd /C  latex "J:\Simo Project\coding5th\testfile.tex"
cmd /C  latex "J:\Simo Project\coding5th\testfile.tex"

**** In the same order, the 2nd compiler converts .dvi to .ps(compiler2.bat)***

Code: Select all


cd\
J:
cd Simo Project
cd coding5th

cmd /C dvips -o  "J:\Simo Project\coding5th\testfile.ps" "J:\Simo Project\coding5th\testfile.dvi"
cmd /C dvips -Ppdf -t letter -o  "J:\Simo Project\coding5th\testfile.ps" "J:\Simo Project\coding5th\testfile.dvi"

**** The last one now compiles .ps to .pdf***(compiler3.bat)

Code: Select all


cd\
J:
cd Simo Project
cd coding5th
cmd /C  ps2pdf14.bat "J:\Simo Project\coding5th\testfile.ps"

You may decide to have the cmds in a single batch file or separately and a main batch to call the three in sequence, which I find also working fine(maincompiler.bat).

Code: Select all


@echo off
cmd /C "J:\Simo Project\coding5th\compiler1.bat"
cmd /C "J:\Simo Project\coding5th\compiler2.bat"
cmd /C "J:\Simo Project\coding5th\compiler3.bat"

Remember it costs you this much
Miktex 2.8/2.7 0$(both should be updated)
TEXnicCenter 0$
Acrobat Reader 0$
......................
TOTAL 0$
....................
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

LaTeX to PDF

Post by frabjous »

What is with all the cmd lines? Why launch a new shell for each process? Why isn't "Simo Project" in quotation marks after "cd"? Why hard-code the paths, rather than simply allowing the path to be passed as an argument? What is in ps2pdf14.bat? Does that come with ghostscript for windows, or is that something you wrote? Why not include bibtex?

If you're using TexNicCenter, why not just run its LaTeX => PS => PDF routine? Why create your own?

Assuming latex, dvips and ps2pdf are all in your path, I'd just use something like:

Code: Select all

cd "%~dp1"
latex --interaction=nonstopmode "%~n1.tex"
bibtex "%~n1.tex"
latex --interaction=nonstopmode "%~n1.tex"
latex --interaction=nonstopmode "%~n1.tex"
dvips "%~n1.dvi"
ps2pdf "%~n1.ps"
(Stick @echo off at the beginning if you want, though I'd prefer to see what happens myself.)

This will allow you to pass the batch file a parameter, so that if it's called compile.bat, you could type in:

compile.bat "J:\Simo Project\coding5th\testfile.tex"

It'll compile and convert that file, but you could pass it anything else instead, including a relative path, I think.

I think that'll work anyway. Been a long time since I wrote a batch file for Windows, and I never ran ghostscript from a shell. I don't have any of these programs installed for Windows to check. (Windows sucks.)

What's wrong with that?

(Or just use pdflatex and be done with it?)
simo
Posts: 18
Joined: Thu Feb 04, 2010 4:27 pm

Re: LaTeX to PDF

Post by simo »

Thaaaaaaaaaannnnnnnnnkkkkk you so much!!!!!!!!
I only needed the "interaction=nonstopmode" cmd to complete my space shuttle and am off to space.Get on board frabjous. My batch file is running perfectly well.
Good day
simo
Posts: 18
Joined: Thu Feb 04, 2010 4:27 pm

Re: LaTeX to PDF

Post by simo »

should this code be in linux or something I tried it in windows but it wont work.
And at least I was able to solve my problem.
Confirm pliz
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Re: LaTeX to PDF

Post by frabjous »

Are you asking me?

The commands I gave were meant for a Windows/DOS batch file, but I didn't actually test it since I don't have LaTeX installed on my Windows partition.

(Of course, writing a bash script that does the same thing for linux is even easier, but would be different.)

If it doesn't work for you, it's a little hard to diagnose without telling me what went wrong.

Run the batch file from the command line, and don't include @echo off, so it shows the actual commands, and copy all the output here, and maybe I can figure out why it isn't working.

"pliz" is not a word.
spiegboy
Posts: 120
Joined: Thu Dec 06, 2007 9:58 am

Re: LaTeX to PDF

Post by spiegboy »

very confused, why do you need to bother to write a batch to do this.
they are available in the edit software
Post Reply