Bad font using \psfrag
You can adjust the horizontal position using \rlap
and \kern
, and the vertical position using \strut
, \smash
and \raisebox
. I cannot show it on your example, but the following might give a hint:
\documentclass{article}
\begin{document}
\newcommand*\ytick[1]{\rlap{\small\kern-0.2em\relax#1}}
\newcommand*\ylabel[1]{\strut\smash{\small\raisebox{0.5ex}{#1}}}
A\ytick{x}B
X\ylabel{a}Y
\end{document}
Meaning of the macros:
\rlap{#1}
typesets#1
on the right from the current position, occupying no space. There are macros\llap
and\clap
as well.\kern#1\relax
inserts a space of size#1
, in this case horizontal (\rlap
's content is in horizontal mode) and negative.\strut
typesets an invisible box of zero width and height+depth of a "maximal size of a letter without accents".\smash{#1}
typesets#1
as if it had no height at all. We use\strut\smash
to ensure that\raisebox
has the desired effect.\raisebox{#1}{#2}
takes#2
and moves it vertically by#1
.
Now, you should be able to write something like \psfrag{358}{\ytick{$358$}}
, and if you play with the value -0.2em
for a while, you get the desired result.
In a similar way you can move the axis label to the left (which means vertically since it's 90 degrees rotated).
Carsten Gade
MSc student at Technical University of Denmark. Studying Physics and Nanotechnology.
Updated on October 30, 2020Comments
-
Carsten Gade about 3 years
I'm trying to include a figure that I made in MATLAB. I want to change the font using
\psfrag
, however there seems to be a problem when scaling the figure down. It keeps the font the same size as the text, which is fine, but the tick labels keep their position (they are overlapping the axes!), which looks bad. See the figure below. MWE follows below.\documentclass[11pt,a4paper]{article} \usepackage[latin1]{inputenc} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{graphicx} \usepackage{psfrag} \begin{document} \begin{figure} \psfrag{0}{$ 0 $} \psfrag{5}{$ 5 $} \psfrag{10}{$ 10 $} \psfrag{15}{$ 15 $} \psfrag{20}{$ 20 $} \psfrag{25}{$ 25 $} \psfrag{30}{$ 30 $} \psfrag{358}{$ 358 $} \psfrag{360}{$ 360 $} \psfrag{362}{$ 362 $} \psfrag{364}{$ 364 $} \psfrag{366}{$ 366 $} \psfrag{368}{$ 368 $} \psfrag{370}{$ 370 $} \psfrag{xtitle}{$ d_{c}\, \mathrm{[\mu m]} $} \psfrag{ytitle}{$ t_{i}\, \mathrm{[nm]} $} \begin{centering} \includegraphics[scale=0.7]{layer_thickness.eps} \par\end{centering} \caption{Insert caption} \label{fig: layer thickness} \end{figure} \end{document}
-
daleif almost 11 yearsThis is normal, you are asking it to insert some text,
psfrag
has no idea which size to use, it can only tellTeX
where to place it. Try adding, say,\footnotesize
just after\begin{figure}
. BTW:centering
is not an environment, and the\par
is unnessary. -
Carsten Gade almost 11 yearsI think I need to use another solution than
psfrag
then. Because no matter the size of the numbers, it's the positioning that I want to change. I want to keep more space from the axes. Any ideas? -
texenthusiast almost 11 years@CarstenGade Did you have a look at matlabfrag to pdf ?. Read the documentation of matlabfrag line 223. Of course there are many options Best way to include Matlab figure
-
Carsten Gade almost 11 years@texenthusiast Thanks for the tip about matlabfrag - that did it for me!
-