如何使用坐标系构建pdf图像(Tikz?)

如何使用坐标系构建pdf图像(Tikz?)

我想知道是否可以在包含的图像周围添加一个框架(通过\includegraphics)。

我想给图像添加坐标系。

答案1

\documentclass{article}
\usepackage{overpic}
\begin{document}

\begin{overpic}[grid, scale=0.5]{tiger.pdf}
\end{overpic}

\end{document}

在此处输入图片描述

答案2

你好,请看一下下面的代码

\documentclass{book}

\usepackage[demo]{graphicx}
\usepackage{tikz}
\begin{document}

%Define grid size type=int
\def\gmin{-2}
\def\gmax{2}

 \begin{tikzpicture}
    % include a graphic with border
    % strip {\color{blue}} its there for a showcase purpose only
    \node[draw, line width=10pt, red, inner sep=0pt, anchor=center] at (0,0) {{\color{blue}\includegraphics[width=100pt, height=100pt]{demo}}};
   % now the manually drawn grid. It uses the  variables from above.
    \foreach \x in {\gmin,...,\gmax} \draw (\x ,\gmin) -- (\x ,\gmax) node[anchor=south] {$\x$};
    \foreach \y in {\gmin,...,\gmax} \draw (\gmin,\y) -- (\gmax,\y) node[anchor=west] {$\y$};


 \end{tikzpicture}

\end{document}

生成的图像

这回答了你的两个问题。备注:有很多方法可以实现这样的目标。如果你更喜欢其他方法,请点击@Jake 给你的链接。

有许多软件包可用于为某物添加框架(大多数软件包的名称中都有“frame”)。一种默认方法(内置于 LaTeX2e)是使用fbox \fbox{\includegraphics[width=100pt, height=100pt]{demo}}

答案3

请阅读给出的评论。

案例 1(使用 4 个象限)

在此处输入图片描述

% please "TeXify" it with xelatex because 
% it imports a PDF image which is explicitly specified by .pdf extension.

\documentclass[border=12pt]{standalone}
\usepackage{graphicx}
\usepackage{pstricks}

\def\M{3}% the number of columns
\def\N{3}% the number of rows
\def\filename{example-image-a.pdf}% filename of the imported image
\def\scale{1}% scalling factor


\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=\scale]{\filename}}

\psset
{
    xunit=0.5\dimexpr\wd\IBox/\M\relax,
    yunit=0.5\dimexpr\ht\IBox/\N\relax,
}

\begin{document}
\begin{pspicture}(-\M,-\N)(\M,\N)
    \rput(0,0){\usebox\IBox}
    \psgrid
\end{pspicture}
\end{document}

案例 2(仅使用第一象限)

在此处输入图片描述

% please "TeXify" it with xelatex because 
% it imports a PDF image which is explicitly specified by .pdf extension.

\documentclass[border=12pt]{standalone}
\usepackage{graphicx}
\usepackage{pstricks}

\def\M{3}% the number of columns
\def\N{3}% the number of rows
\def\filename{example-image-a.pdf}% filename of the imported image
\def\scale{1}% scalling factor


\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=\scale]{\filename}}

\psset
{
    xunit=\dimexpr\wd\IBox/\M\relax,
    yunit=\dimexpr\ht\IBox/\N\relax,
}

\begin{document}
\begin{pspicture}(\M,\N)
    \rput[bl](0,0){\usebox\IBox}
    \psgrid
\end{pspicture}
\end{document}

相关内容