1

I have a chart in PDF format, which had been cropped to have no margin using pdfcrop

enter image description here

Months later, I realized that I need to add X- and Y- axis labels. Because I don't have the original script to generate the figure, I edited the PDF by adding a narrow margin to the left- and bottom corners:

pdfcrop --margin '20 0 0 20' fig_tight_cropped.pdf fig_with_axis_labels.pdf

And then edited the PDF and added the X and Y labels (using Mac's preview tool)

enter image description here

However, when I put them in a latex file, PDFLatex makes them appear exactly the same and ignores the added margin in the second file.

Here is the minimum working example:

\documentclass{article}
\usepackage{graphicx}

\begin{document}

\begin{figure}[h!]
\includegraphics{fig_tight_crop.pdf}
\includegraphics{fig_with_axis_labels.pdf}
\end{figure}

\end{document}

And the output looks like this:

enter image description here

How can I make the margins appear? Why does it disappear in the first place?

P.S. Here are the figures with and without the margin:

fig_tight_cropped.pdf

fig_with_axis_labels.pdf

0

1 Answer 1

1

You can add annotations to an image using tikz.

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  \pgftext{%
  \includegraphics[width=\textwidth]{fig_tight_cropped}%
  }%
  \node[xshift=-6.5cm,rotate=90] {$C_d$};
  \node[yshift=-4.4cm] {$C_x$};
\end{tikzpicture}

\end{document}

The tikz-imagelabels package could help in placing annotations:

\documentclass{article}
\usepackage{tikz-imagelabels}

\imagelabelset{
  image label distance=-7mm,
  image label back=none,
  image label text=black}

\begin{document}
    
\begin{annotationimage}{width=\textwidth}{fig_tight_cropped}
  \draw[image label = {$C_x$ at south}];
  \draw[image label = {\rotatebox{90}{$C_d$} at west}];
\end{annotationimage}
    
\end{document}

The first solution gives you a lot more possibilities. For example you can add a coordinate system and other annotations wherever you like:

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  \node [anchor=south west] at (0,0) {\includegraphics[width=\textwidth]{fig_tight_cropped}};
  \draw [very thick,draw=red,->] (0,0) -- (0,7) node[below left,midway] {$C_x$};
  \draw [very thick,draw=red,->] (0,0) -- (7,0) node[midway, below left] {$C_d$};
  \node at (5,6) {An annotation here};
\end{tikzpicture}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .