include figure files in latex [closed] - latex

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I am trying to include jpeg files in latex
\includegraphics[width=57.6mm, height=43.2mm]{../../results2/html/zerooneloss_stumps.jpg}
With specified the width and height and compiled with pdflatex, however, it produces the error:
! LaTeX Error: Cannot determine size of graphic in ../../results2/html/zerooneloss_stumps.jpg (no BoundingBox).
The true size of the image is 576x432 in pixels. Have I specified the size correctly in the latex file?
Anyway to use the default setting without need to specify the width and height? If I don't specify the them in the latex file,
\includegraphics[]{../../results2/html/zerooneloss_stumps.jpg}
I still get the same no BoundingBox error.
Thanks and regards!
Change
\includegraphics[]{../../results2/html/zerooneloss_stumps.jpg}
to
\includegraphics{../../results2/html/zerooneloss_stumps.jpg}
still has the no BoundingBox error.
I am using
\usepackage[dvips]{graphicx}
What is the difference between it and
\usepackage{graphicx}
It seems with the former one, eps figure files can work while jpeg files cannot, with the latter, things become reverse?
Is it possiblt to include figure files of both eps and jpg in the same latex file?

Do you have \usepackage{graphicx} in your preamble?
EDIT (consequent of an edit in the question): you should not use the dvips option when using pdflatex. The option produces informations useful for the postprocessing of the dvi output of the latex program (e.g. via dvips). In you case, since you are using pdflatex you should simply not give any option to the graphicx package (the right driver is choosen automatically). On the other hand pdflatex only supports external graphics in PNG, JPG or PDF format, but, as other have said, it's easy to convert EPS to PDF: my preferred way is to use epstopdf that in Ubuntu is provided by the texlive-extra-utils package.
For example, when processed with pdflatex, the following example works if you have a file image.png or image.jpg or image.pdf in the current directory:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics{image}
\end{document}

You have to add the package option pdftex to the package graphicx:
\usepackage[pdftex]{graphicx}

try \includegraphics{myfig.jpg}
when you say [width=57.6mm, height=43.2mm] it's the box size in millimeters (mm). latex scales your image to this dimension.
more scale options: http://amath.colorado.edu/documentation/LaTeX/reference/figures.html
For the no Bounding Box error:
What's a BoundingBox?
A BoundingBox is a entry that is located in PostScript files that tells the reader the scale limits of the file. Latex uses this entry to determine how to place the image in the document.
How to fix my Latex problem
It is quite easy to fix this problem. The software package ImageMagick is used in this case to convert the images from one form to another. ImageMagick is able to convert many image formats to many other types. To do the conversion just enter this into your console:
root#Pingu ~ # convert image.jpg image.eps
http://www.tuxpages.com/helppages/latex-convert.shtml

Related

Is it possible to insert a gif in latex (Overleaf)? [duplicate]

This question already has an answer here:
How to add a gif/animation onto Beamer (post Adobe retiring Flash)
(1 answer)
Closed 26 days ago.
I'm writing a latex file on Overleaf and I would insert a gif image.
Is it possible? Because I didn't find any solutions.
I had the same problem and I solved it by converting the gif to a set of pngs and then using the animate package.
For the first task you can exploit one of the solution suggested here.
Once you have a series of image files named with a shared prefix (e.g. fig-) and an increasing index that track the order in which they have to appear, then the usage of `animate} is pretty simple:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx, animate}
\title{animate SO}
\date{January 2022}
\begin{document}
This is how to insert gif in main document:
% use the usual figure environment and substitute \includegraphics with \animategraphics
\begin{figure}
\centering
% \includegraphics{}
\animategraphics[width=\textwidth, loop, autoplay]{1}%frame rate
{figures/fig-}%path to figures
{1}%start index
{4}%end index
\caption{Local gif}
\label{fig:my_label}
\end{figure}
\end{document}
Notice that I needed to express the path to the location of the figures as./figures/<fig-prefix> in case the \animategraphics is called by an external tex file which is included in the main.
I created a sample overleaf project to showcase the usage.
Finally, I'd suggest have a look to StackExchange LaTeX for latex related question :)

How do I convert from postscript/gnuplot to pdf maintaining accented letters for latex document?

So I have to write my lab report in Italian for my lab class. In class they taught us how to use gnuplot to create graphs, so I'm using it to produce our graphs, which then I need to put in my latex document. The problem is that I have to set the label on the y axes as "velocità", and when I then save the file in ps and convert in pdf the 'à' disappears or is substituted by something else. What I've tried doing is using variations of the commands
set encoding iso_8859_1
set ylabel "velocit\340"
then I saved the plot using set term postscript color, set output "graf.ps", replot, and from the wsl terminal, using ps2pdf, I converted it into a pdf, but when I open the pdf, the letter 'à' doesn't appear anymore, even though it did show in graph previously generated by gnuplot. What should I do? In case, is there another way I can attach the original graph in my latex document?
Gnuplot provides several LaTeX-friendly terminal types. Postscript is not one of them. Postscript's character encodings are idiosyncratic at best. If your goal is to include gnuplot output in latex, then choose a terminal type that is designed for it. Some terminal types (e.g. cairolatex) work only with latex because they depend on latex to do all the text processing. Others (e.g. pdf, png, tikz) produce output that is fully compatible with latex but already has the text embedded in it. It is best to use UTF-8 encoding for everything, including your accented characters. For example:
set term pdf size 7cm,5cm
set output 'myfigure.pdf'
set encoding utf8
set ylabel "velocità"
set xlabel "tempo"
plot [0:10] x**2 title "velocità"
Then in your latex document, something like:
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
...
My TeX document.
\begin{figure}[h]
\includegraphics{myfigure}
\end{figure}
...

comparison of latex with postscript [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I came across latex both as a saving format and drawing framework under libreoffice and goffice.
I also came across djvu as an alternative to pdf, which uses latex instead of postscript.
Now, postscript is adobe's base for flash animations, and is thus vector graphics tagged under a script.
So for me, latex looks like an alternative to postscript. Or can latex substitute postscript?
Postscript is a scripted programming language with built-in graphics and font-rendering primitives. It can be used as a word-processor's output format, but usually requires to word-processor to do all the text-placement calculations. Output can be post-processed to PDF.
TeX (I'll get to LaTeX in a moment) is a document-processing language. It performs text-placement calculations and font-rendering but lacks the drawing facilities of postscript. TeX output is normally a .dvi (device-independent document) file which can be post-processed into postscript.
LaTeX basically adds style-sheets to TeX, higher-level concepts like "chapter" and "section".
So you end up with a chain. LaTeX -> TeX -> DVI -> PS -> PDF (mirroring the earlier chain: pic | eqn | tbl | groff). Later versions of LaTeX have merged several of these conversions. DVI, PS, and PDF are all equally good, but you may prefer one to the others depending on what other software you wish to use. There's a popular package for LaTeX called PSTricks which requires you to have PS in the chain.
So they're all different, but the same, you know?
It may be helpful to enumerate which of these formats cannot be converted into one of the others.
LaTeX -> TeX. You cannot really go the other way. I'm not sure it makes any sense.
TeX -> DVI. Again, this is a "rendering" step, so you can't go backwards. Like you can't convert a photograph of an apple into an apple.
DVI -> PS. PS -> DVI. DVI -> PDF. PDF -> DVI (never heard of this, but why not?!). PS -> PDF. PDF -> PS (unless you're using PDF layers which don't exist in PS). These three, treated as output formats are readily inter-convertible.
As input formats, LaTeX, TeX, and PS have very different problem-domains. While theoretically each has the power to perform the proper work of one of the others, it'd be a gaudawful mess. For examples, look up "Line-breaking in Postscript" (you end-up having to re-implement a whole mess of algorithms for which library versions would be readily available in almost any other language) or "Image-Processing in Tex" (you make a "font" of halftone spots and then "print" your image by setting text in that font). DVI and PDF are not really human-read/write-able; they are only "output" formats (except, of course, to post-processing software, to whom they are "input").
LaTeX is a language for easily writing documents, and Postscript is like PDF, so both aren't comparable. latex produces postscript documents. think it like LaTeX is C source code, and postscript the executable produced by compilation.

Latex, TikZ and separate compilation of chapters and figures

I have fairly large Latex document with a lot of TikZ figures inside. I have a habit of frequent recompilation and it takes forever to compile it using pdflatex. Figures in TikZ take most of the time.
My question is what is the best way to split the document into separate tex files (figures/chapters) to achieve separate compilation of figures and chapters, separate chapter pdfs, and a whole document pdf file ?
Have you tried compiling each picture on its own and then including them in your tex file as pdf rather than the tikz code? You can use the package standalone so that the picture will be the exact size you need. So :
\documentclass{standalone}
\usepackage{tikz,pgf} %and any other packages or tikzlibraries your picture needs
\begin{document}
\begin{tikzpicture}
%your tikz code here
\end{tikzpicture}
\end{document}
The good thing about this is that you can either include the compile this document directly to get a pdf figure to include in your document, or you can use the command \input to include it in your main document as a tikz code by adding
\usepackage{standalone}
in your main document (together with the tikz packages and libraries), and then
\begin{figure}
\input{tikzfile.tex}
\end{figure}
There is a possibly better way (imho) to cache tikz-pictures. Add the following lines in your
preamble:
\usetikzlibrary{external}
\tikzexternalize[prefix=i/]
After a pdflatex-run you'll see all pictures in the subdirectory ./i .
If you update the code of a tikz-picture simply throw away its corresponding pdf-file and it will be regenerated. For more info see the manual of PFG/TikZ section 32.4 Externalizing Graphics
and possibly 32.5 Using External Graphics Without pgf Installed.
How about putting each chapter in a separate file and then using \include to put them into some master file? Then you can use \includeonly to only compile the chapter you're currently working on. That should save some time at least.
I expect some sort of makefile based solution would be even better than this, but I don't know anything about makefiles...
The way I generally do this is to apply Latex to just part of the file: Emacs and several other Latex editors allow you to compiler regions: with Auctex, you can run TeX-pin-region to specify the current chapter, and then TeX-command-region to run Latex on the selected region.
The traditional way to do this is cut parts of the big file into smaller parts that are \included, and then either comment out parts you don't want to work on, or put some macrology at the beginning and end of each file that allows them to be compiled separately.

Convert EPS to PDF on the fly with pdflatex on the fly

I'm trying to include an EPS figure in a document that will be compiled using pdflatex. Of course, the picture can be converted to pdf using epstopdf (which comes with the MikTeX distribution). Is there any way to do this on the fly, that is, make pdflatex do the conversion?
I'm looking for such a solution because I want to set up an easy-to-learn environment for students. Ideally, the converted picture is placed in the directory that also contains the original .eps, and the .pdf is used if available.
The relevant answer in the TeX FAQ points to epstopdf.sty, included with Heiko Oberdiek's packages.
I would recommend using latex-mk which is a nice way to have a very simple Makefile for latex construction. Of course you can have eps file converted to pdf, or fig to eps, etc, during the build process.
Currently my Makefile look like that :
NAME=report
TEXSRCS=report.tex
BIBTEXSRCS=biblio.bib
USE_PDFLATEX=true
VIEWPDF=open # cause i'm on osx, gv for most unix
XFIGDIRS=img
## For osx users :
include /opt/local/share/latex-mk/latex.gmk
## For unix users :
#include /usr/share/latex-mk/latex.gmk
When I invoke make, the first thing it does is converting some .fig into .pdf files. I'm pretty sure it would do the same with eps files.
If you want to include one EPS figure in latex then you need to at first make the figure in EPS format if it is not in EPS format.Like if your figure is in .jpeg extension, then you need to make it .eps
Then you need to include it in the LaTex with using some code which is common in LaTex and then to make it in pdf format you need to use one small instruction that is \usepackage{epstopdf}
I was also facing this problem and found this post very helpful "How to Convert .eps to PDF in Latex ?"
Now i am able to include EPS figure in LaTex and also can convert it in PDF. I think you will also get help and all the details from the above link.Let me know if you face any further problem.

Resources