0

I am writing my thesis and have generated eps graphs in stata which I have included in the text. However, I am unhappy with the graph fonts and will be happy if someone can point me to a way to change the graph fonts to match that of the text.

Thanks in advance.

  • Welcome! Many external software programmes allow you to include the labels etc. as TeX code or to delay insertion of the content until compilation. Does stata have such an option? That is, can it cooperate with TeX in this way? – cfr Mar 19 '17 at 4:11
  • No stata has no such, at least not that I know of. I tried generating the tex codes with inkscape then compiling then inserted the tex link in the content but I can't seem to get to work either. I have read about psfrag but I am using pdflatex so i have found no luck with that either. – user68 Mar 19 '17 at 4:18
  • Well, a very complicated solution would be to include the eps files in standalones, use psfrag, produce ps and then convert this to pdf. But I admit that this is not very elegant. – user121799 Mar 19 '17 at 4:39
  • As ignorant of Stata, my idea would be remake the graphs in R code using knitr (example), but only you can answer if is possible make the same graphs with R or if it is worth the effort of learn/use another statistical software only for this. Personally, I do not care of a sans serif font in graphs while having a reasonable size with respect the roman text (in fact, I think that look better with different fonts). – Fran Mar 19 '17 at 7:58
2

Package psfrag is your friend.

Here is an example with Palatino fonts in the document, which embeds a Gnuplot graphics with sans serif (DejaVuSans to be precise) fonts

\documentclass{acmart}
\pagestyle{empty}
\usepackage{graphicx}
\usepackage{psfrag}
\usepackage{mathpazo}
\begin{document}

Here is a graph using gnuplot fonts:

\includegraphics{sin.eps}


Now let us use psfrag.  Note that gnuplot writes down positive numbers
space-padded, so use \verb*| 1| for 1, but \verb*|-1| for -1 in tags.  

\begin{psfrags}
\psfrag{sin(x)}{$\sin(x)$}
\psfrag{ 1}{$1$}
\psfrag{ 0.8}{$0.8$}
\psfrag{ 0.6}{$0.6$}
\psfrag{ 0.4}{$0.4$}
\psfrag{ 0.2}{$0.2$}
\psfrag{ 0}{$0$}
\psfrag{-0.8}{$-0.8$}
\psfrag{-0.6}{$-0.6$}
\psfrag{-0.4}{$-0.4$}
\psfrag{-0.2}{$-0.2$}
\psfrag{-1}{$-1$}
\psfrag{ 10}{$10$}
\psfrag{ 5}{$5$}
\psfrag{-10}{$-10$}
\psfrag{-5}{$-5$}
\includegraphics{sin.eps}  
\end{psfrags}

\end{document}

enter image description here

  • 2
    Nice solution. The minuses on the y axis seem to missing, though. – gernot Mar 19 '17 at 8:28
  • A typo in my psfrag substitutions. Thanks for noticing this. Corrected. – Boris Mar 19 '17 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.