TeXShopedit figures to match layout of text

Information and discussion about TeXShop, an integrated LaTeX environment for Mac OS X
Post Reply
Xenabelle
Posts: 1
Joined: Mon Jul 28, 2008 10:18 pm

edit figures to match layout of text

Post by Xenabelle »

Hi,

I'm new to both LaTex and mac and I'm having some difficulties with importing pictures.
I have pictures with text in them but the text is very different to the text in the rest of the article.

Is there a way or program to import text in a figure in such a way that when you import the figure in LaTex, that the layout is the same?

Regards,
Xenabelle

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

edit figures to match layout of text

Post by Ted »

Xenabelle wrote:I'm new to both LaTex and mac and I'm having some difficulties with importing pictures.
I have pictures with text in them but the text is very different to the text in the rest of the article.

Is there a way or program to import text in a figure in such a way that when you import the figure in LaTex, that the layout is the same?
If those pictures are in EPS format, you can use the psfrag package to give LaTeX access to text within the figure.
In other words, within your document you can tell LaTeX to substitute text found in the figures with text generated via LaTeX.

Of course, if you use EPS files, you'll have to use latex, dvips, and ps2pdf to generate a PDF (i.e., you won't be able to use pdflatex directly).

[ Note that some programs (like MATLAB) let you call out to LaTeX on generation of your figures. That way you can be sure the fonts match up even if you don't use psfrag. ]
-- Ted [home/blog]
User avatar
T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

edit figures to match layout of text

Post by T3. »

You could also try eps2pgf utility. It will convert .eps graphic into PGF format that can be directly inputed into your document (you will also need to add pgf/tikz package to your preamble). The advantage over psfrag is that even text not replaceable by psfrag should be converted to LaTeX in this way.

@Ted
MATLAB does not let you customize LaTeX preamble, so you always get Computer Modern fonts. There is no way to match fonts if you use something else in your document.

Cheeers,

Tomek
Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

edit figures to match layout of text

Post by Ted »

T3. wrote:You could also try eps2pgf utility. It will convert .eps graphic into PGF format that can be directly inputed into your document (you will also need to add pgf/tikz package to your preamble). The advantage over psfrag is that even text not replaceable by psfrag should be converted to LaTeX in this way.
The disadvantage of this method is that you have to make your changes every time you regenerate your EPS. Alternatively, using PSFrag, I can make graphics changes and not worry about going back and making text changes later.
T3. wrote:@Ted
MATLAB does not let you customize LaTeX preamble, so you always get Computer Modern fonts. There is no way to match fonts if you use something else in your document.
I gave MATLAB as an example. Maybe I should have said "XFig" instead. I wanted to mention MATLAB because few people realize that they can change their Interpreter settings to 'latex'. Even those who realize there is an interpreter setting may think that they're restricted to the 'tex' setting.

Regardless, I should think that most users needing this functionality will be generating compuscripts in which CM fonts can be used throughout. Users are free to change font shape, and that's the most important degree of freedom in most cases.
-- Ted [home/blog]
User avatar
T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

edit figures to match layout of text

Post by T3. »

About MATLAB: I know, you know, Ted. But since the question was about font matching, I thought it won't be bad to clarify that. I mentioned it because I actually faced that problem with MATLAB - majority of LaTeX documents use CM fonts, so they look dull and I wanted a different one but couldn't find a way to hack around MATLAB's implementation of TeX (and it's a very unusual one - TeX is run as a dynamic library, entire compilation happens in memory and nothing is written to disk).

But I digress. About psfrag it should also be mentioned that it can't be used directly with pdflatex.

There is also another option that might be especially appealing to Windows' users. There is a program called TpX (Windows only but there is an alpha Linux port) that understands clipboard format so graphics can be just copy-pasted into it. It then splits the text from the graphic and puts it in a standard LaTeX picture environment that is drawn on top of the graphic. Supports both, latex and pdflatex, routes.

The advantage of having text in the standard LaTeX picture environment is that it will be supported even if you send your work to a publisher. The same does not have to be necessarily true for psfrag and even less so for pgf package, which is very young (but really impressive). And for those who are willing to position their text manually, there is overpic package that also places picture environment on top of the included graphic.

Cheers,

Tomek

Edit:
Ups, I just realized that I suggested a Windows program to a Mac user :roll: . Scratch that.
Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

edit figures to match layout of text

Post by Ted »

Ted wrote:
T3. wrote:MATLAB does not let you customize LaTeX preamble, so you always get Computer Modern fonts. There is no way to match fonts if you use something else in your document.
I gave MATLAB as an example. Maybe I should have said "XFig" instead.
I meant to say IPE there. There are many (cross-platform) solutions that replace old standards (like XFig and jFig) that support direct entry of LaTeX.

Of course, jfig works well with psfrag.
T3. wrote:But I digress. About psfrag it should also be mentioned that it can't be used directly with pdflatex.
And I did, in my original message, in a single line that's probably too easily to be skimmed over. I should have made that more clear.
T3. wrote:There is also another option that might be especially appealing to Windows' users. There is a program called TpX (Windows only but there is an alpha Linux port) that understands clipboard format so graphics can be just copy-pasted into it. It then splits the text from the graphic and puts it in a standard LaTeX picture environment that is drawn on top of the graphic. Supports both, latex and pdflatex, routes.
T3. wrote:Ups, I just realized that I suggested a Windows program to a Mac user :roll: . Scratch that.
For similar functionality, Mac users can use the LaTeX Equation Editor (or one of the many programs that do the same thing) to copy and paste LaTeX snippets (or generate tiny PDF's of snippets directly). You can adjust the LaTeX preamble in LEE.
T3. wrote:The advantage of having text in the standard LaTeX picture environment is that it will be supported even if you send your work to a publisher. The same does not have to be necessarily true for psfrag and even less so for pgf package, which is very young (but really impressive).
You can use the preview package (or the pst-eps package) to solve this problem. Put all of your TeX magic in a separate file, and build your figure separately. Include it within your main TeX file as if it was a complete graphic needing no modification. Then submit to your publisher your main document and all of the derived graphics. The publisher doesn't even have to know you used TeX to produce them. That's what I do (even with standard picture and pspicture environments).
-- Ted [home/blog]
User avatar
T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

edit figures to match layout of text

Post by T3. »

Ted wrote:
T3. wrote:But I digress. About psfrag it should also be mentioned that it can't be used directly with pdflatex.
And I did, in my original message, in a single line that's probably too easily to be skimmed over. I should have made that more clear.
Ups again. I should read more carefully.
Ted wrote:
T3. wrote:The advantage of having text in the standard LaTeX picture environment is that it will be supported even if you send your work to a publisher. The same does not have to be necessarily true for psfrag and even less so for pgf package, which is very young (but really impressive).
You can use the preview package (or the pst-eps package) to solve this problem. Put all of your TeX magic in a separate file, and build your figure separately.
[...]
What I meant is that if publisher uses some proprietary fonts (and limits the use of nonstandard packages) then preparing graphics upfront will not help. Text typesetting have to happen on the publisher's end. Picture environment (but not it's extensions) is part of LaTeX's core so it must be supported, for other packages it's worth to check beforehand if they can be used (one can also sent a paper with all the required style files - psfrag comes in just one small file, but packages like ps-tricks or pgf are quite gigantic).

Cheers,

Tomek
Post Reply