Showing posts with label Science. Show all posts
Showing posts with label Science. Show all posts

PDFLaTeX with EPS and PNG Figures

Take a look at this trick in the post at http://opendevice.blogspot.com/2008/05/eps-files-and-pdflatex.html. The idea is simple. It asks for converting eps figures into pdf figures before compiling the tex file. But it is necessary to remember that only the name, not the .eps extension, of eps figures can be placed in\includegraphics{}; otherwise the eps figures will be converted every time the tex file is compiled.


"There is this odd quirk in LaTeX. The latex executable compiles your .tex files in the old-fashioned DVI format. As such, it accepts by default only .eps (Encapsulated PostScript) images. pdflatex compiles your .tex files in the standard PDF format. For some mysterious quirk, pdflatex accepts raster formats like .png and .jpg , but does not accept .eps!

Sometimes you want the best of both worlds. An undergraduate of my lab, after some googling, found you can force pdflatex to insert .eps files happily:

1)Install texlive-extra packages, or any other package containing the epstopdf utility.

2) Insert the following code in your .tex file:

\newif\ifpdf
\ifx\pdfoutput\undefined
\pdffalse
\else
\pdfoutput=1
\pdftrue
\fi
\ifpdf
\usepackage{graphicx}
\usepackage{epstopdf}
\DeclareGraphicsRule{.eps}{pdf}{.pdf}{`epstopdf #1}
\pdfcompresslevel=9
\else
\usepackage{graphicx}
\fi

3) Compile using pdflatex with the -shell-escape command line option

It seems to work."

Extract Plot Data from Scientific Papers

The way for extracting plot data from scientific papers is simple once the right tools have been utilized. On the internet there exist numerous software for serving this purpose but I prefer to use the free ones and those under GNU General Public License. Specifically, the following three are my favorite:

A. Engauge Digitizer - Digitizing software;
B. The Ipe extensible drawing editor;
C. MS Paint - a little drawing tool on Microsoft Windows.

1. Extract the plot as an image file.
This step is quite easy if the paper is already in the pdf format. Open the pdf, enlarge the plot, make a screen capture, paste the capture into MS Paint, cut the plot area, paste the plot into a new file in MS Paint and then save the plot into an image file. But you need to first scan the paper into an image file if it is only a Xerox photocopy. After that, proceed with the scanned image in the same procedure as those for the pdf file.

2. What if the plot is rotated and has undefined coordinates origin?
This could be a rare case but it did happen to me. Here is an example...
So I used the Ipe drawing editor to define a better coordinate system for the above plot...
Please refer to the Ipe manual on how to do this.

3. Data extraction
This step is simple enough. Import the plot image into the Engauge Digitizer, define the coordinates with three points (red crosses), set data points (blue crosses) on the curve in the plot, and then extract the data values into a .csv file.

Job done!

Texmaker and WinEdt with Foxit PDF Reader

This shows how to customize the Foxit PDF Reader as the PDF viewer for Texmaker and WinEdt.

=============================
Texmaker with Foxit PDF Reader
=============================
1. Make a MSDOS batch file called "viewpdf.bat" in its installation folder with the following lines:

taskkill -fi "windowtitle eq %1*"
start %1
REM "C:\Program Files\Foxit Software\Foxit Reader\Foxit Reader.exe" %1

2. If Foxit PDF Reader is not your default PDF viewer, comment out the second the line, uncomment the third line and make sure the path to the Foxit PDF reader is correct in the "viewpdf.bat".

3. Then open Texmaker and go to "options -> Configure Texmaker" and change the "PDF viewer" to "viewpdf.bat" using the program browsing button.

=============================
WinEdt with Foxit PDF Reader
=============================
Reference: alternative PDF viewer in WinEdt 5.3

1. Add to "Startup.edt" located at PATH_TO_WinEDT\Local\ the following two lines

Assign('AcroRead','"C:\Program Files\Foxit Software\Foxit Reader\Foxit Reader.exe"');
Assign("Acro-Title","Foxit Reader");

and make sure the path to Foxit PDF Reader is correct.

2. Open WinEdt and go to "Macros -> Run startup macro" to refresh the PDF viwer.

3. Add to "Acrobat OpenDoc.bat" located at the PATH_TO_WinEDT\Exec\ the following two lines under "PushTagsandRegisters;":

// Foxit?

FindInString(`%$('AcroRead');`,'Foxit',1,2,1000,1);
IfOK(!"Relax;",!"JMP('not_foxit')");
Run('taskkill -fi "windowtitle eq %N.pdf*"','%P',0,1);
Run('%$("AcroRead"); "%P\%N.pdf"');
RestoreRegisters(1111111111);
Exit;

:not_foxit::

4. Add to "Acrobat CloseDoc.bat" located at the PATH_TO_WinEDT\Exec\ the following two lines under "Requires(20040114);":

// Foxit?
FindInString(`%$('AcroRead');`,'Foxit',1,2,1000,1);
IfOK(!"Relax;",!"JMP('not_Foxit')");
LetRegNum(1,0);
:next_Foxit::
LetRegNum(1,%!1+1);>
IfNum(%!1,99,'>',!"JMP('closed_Foxit')");>
SendMessage("%N - Foxit",$0111,$E152);
IfOK(!"JMP('closed_Foxit')",!"Relax;");
SendMessage("- Foxit",$0111,$E151);
JMP('next_Foxit');
:closed_Foxit::
RestoreRegisters(1111111111);
Exit;
:not_Foxit::

=============================
Automate TeXing with WinEdt
=============================
1. Write a macro called "PDFLatexMacro.edt" as below

Do("Exe('%b\Exec\MikTeX\PDFLaTeX.edt');");
IfOK(!"Relax;",!"JMP('not_SUCCESS')");

Do("Exe('%b\Exec\MikTeX\BibTeX.edt');");
IfOK(!"Relax;",!"JMP('not_SUCCESS')");

Do("Exe('%b\Exec\MikTeX\PDFLaTeX.edt');");
IfOK(!"Relax;",!"JMP('not_SUCCESS')");

Do("Exe('%b\Exec\MikTeX\PDFLaTeX.edt');");
IfOK(!"Relax;",!"JMP('not_SUCCESS')");

Do("Exe('%b\Exec\Acrobat OpenDoc.edt');");

:not_SUCCESS:: // jump to end
End;

and a macro called "DVILatexMacro.edt" as below

Do("Exe('%b\Exec\MikTeX\LaTeX.edt');");
IfOK(!"Relax;",!"JMP('not_SUCCESS')");

Do("Exe('%b\Exec\MikTeX\BibTeX.edt');");
IfOK(!"Relax;",!"JMP('not_SUCCESS')");

Do("Exe('%b\Exec\MikTeX\LaTeX.edt');");
IfOK(!"Relax;",!"JMP('not_SUCCESS')");

Do("Exe('%b\Exec\MikTeX\LaTeX.edt');");
IfOK(!"Relax;",!"JMP('not_SUCCESS')");

Do("Run(|%$('DVIView'); -1 ""%P\%N.dvi""|);");

:not_SUCCESS:: // jump to end
End;

and place them under PATH_TO_WinEDT\Macros\Recorder\.

2. Open WinEdt, go to "Options -> Menu Setup", double-click "&Tools", and then right-click the menu items to insert the two macros above.

MiKTeX's Secret: Local Package Repository

The error in the installation of LaTeX packages from a local package repository on MiKTeX might be:

".... does not seem to be a local package repository".

The problem can be solved by downloading "readme.txt", "miktex-zzdb1.cab", and "miktex-zzdb2.cab" into the folder that contains the LaTeX packages you wish to install.