我正在尝试按如下方式定位我的图像。问题是,当我删除位于原点的黑点时,我的图像的定位就乱了。我的第二个问题是,我将图像与文本混合。现在它从文本后开始,但不与文本内联。这就是我想要实现的。这是我的代码:
\documentclass{beamer}
\usepackage{graphicx} % Allows including images
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{comment}
\usepackage{listings}
\usepackage{hyperref,xcolor}
\usepackage{empheq}
\newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}}
\usepackage{ragged2e}
\usepackage{textcomp}
\usepackage{amsmath, amssymb}
\usepackage{lmodern}
\usepackage{etoolbox}
\usepackage{framed}
\usepackage{varwidth}% http://ctan.org/pkg/varwidth
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,tikzmark,arrows,shapes,backgrounds}
\usepackage{xparse}% For \NewDocumentCommand
\usepackage{calc}% For the \widthof macro
\newcommand{\Text}{Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed accumsan nulla ac ipsum elementum interdum. }
\newcommand{\mytikzmark}[1]{\tikz[overlay,remember picture] \node[baseline] (#1) {};}
\makeatletter
\NewDocumentCommand{\DrawBox}{s O{}}{%
\tikz[overlay,remember picture]{
\IfBooleanTF{#1}{%
\coordinate (RightPoint) at ($(left |- right)+(\linewidth-\labelsep-\labelwidth,0.0)$);
}{%
\coordinate (RightPoint) at (right.east);
}%
\draw[red,#2]
($(left)+(-0.2em,0.9em)$) rectangle
($(RightPoint)+(0.2em,-0.3em)$);}
}
\NewDocumentCommand{\DrawBoxWide}{s O{}}{%
\tikz[overlay,remember picture]{
\IfBooleanTF{#1}{%
\coordinate (RightPoint) at ($(left |- right)+(\linewidth-\labelsep-\labelwidth,0.0)$);
}{%
\coordinate (RightPoint) at (right.east);
}%
\draw[red,#2]
($(left)+(-\labelwidth,0.9em)$) rectangle
($(RightPoint)+(0.2em,-0.3em)$);}
}
\makeatother
\usepackage{pifont}
\newcommand{\titem}{\ding{226}\quad}
\usepackage{tabu}
%----------------------------------------------------------------------------------------
% TITLE PAGE
%----------------------------------------------------------------------------------------
\title[Lecture 2: Visualization and Programming]{Introduction to programming in MATLAB} % The short
\date{} % Date, can be changed to a custom date
\subtitle{Lecture 2: Visualization and Programming}
\begin{document}
% For every picture that defines or uses external nodes, you'll have to
% apply the 'remember picture' style. To avoid some typing, we'll apply
% the style to all pictures.
\tikzstyle{every picture}+=[remember picture]
\tikzstyle{na} = [baseline=-.5ex]
\begin{frame}{Surface Plots}
\begin{itemize}
\item It is more common to visualize surfaces in 3D
\item Example:
\begin{subequations}
\begin{empheq}[box=\widefbox]{align*}
&f(x,y)=sin(x)cos(y), \\
&x\in [-\pi , \pi]; y \in[-\pi ,\pi ]
\end{empheq}
\end{subequations}
\item \textcolor{orange}{\textbf{surf}} puts vertices at specified points in space x,y,z, and connects all the vertices to make a surface
\item The vertices can be denoted by matrices X\tikz[na] \coordinate (s-mat); ,Y\tikz[na] \coordinate (s-gray);,Z
\item How can we make these matrices
\begin{itemize}
\item loop (DUMB)
\item built-in function: \textcolor{orange}{\textbf{meshgrid}}
\end{itemize}
\end{itemize}
\tikzstyle{background grid}=[draw, black!50,step=.5cm]
\begin{tikzpicture}[show background grid]
\node [inner sep=0pt] (X) at (7,.50) {X};%\includegraphics[width=2cm]{X}
\node [inner sep=0pt](Y) at (9,1){Y};%\includegraphics[width=2cm]{Y}
% show origin
\fill (0,0) circle (2pt);
% define destination coordinates
\path (X) coordinate (mat)
(Y) coordinate (gray);
\end{tikzpicture}
\begin{tikzpicture}[overlay]
\path[->,black,thick] (s-mat) edge (mat);
\path[->,black,thick] (s-gray) edge (gray);
\end{tikzpicture}
\end{frame}
\end{document}
以上是我想要的结果。下面是我的实际输出(根据 Sigur 的建议)。
答案1
我使用了 2 个\parbox
es 并排插入。
\documentclass{beamer}
\usepackage{graphicx} % Allows including images
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{comment}
\usepackage{listings}
\usepackage{hyperref,xcolor}
\usepackage{empheq}
\newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}}
\usepackage{ragged2e}
\usepackage{textcomp}
\usepackage{amsmath, amssymb}
\usepackage{lmodern}
\usepackage{etoolbox}
\usepackage{framed}
\usepackage{varwidth}% http://ctan.org/pkg/varwidth
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,tikzmark,arrows,shapes,backgrounds}
\usepackage{xparse}% For \NewDocumentCommand
\usepackage{calc}% For the \widthof macro
\newcommand{\Text}{Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed accumsan nulla ac ipsum elementum interdum. }
\newcommand{\mytikzmark}[1]{\tikz[overlay,remember picture] \node[baseline] (#1) {};}
\makeatletter
\NewDocumentCommand{\DrawBox}{s O{}}{%
\tikz[overlay,remember picture]{
\IfBooleanTF{#1}{%
\coordinate (RightPoint) at ($(left |- right)+(\linewidth-\labelsep-\labelwidth,0.0)$);
}{%
\coordinate (RightPoint) at (right.east);
}%
\draw[red,#2]
($(left)+(-0.2em,0.9em)$) rectangle
($(RightPoint)+(0.2em,-0.3em)$);}
}
\NewDocumentCommand{\DrawBoxWide}{s O{}}{%
\tikz[overlay,remember picture]{
\IfBooleanTF{#1}{%
\coordinate (RightPoint) at ($(left |- right)+(\linewidth-\labelsep-\labelwidth,0.0)$);
}{%
\coordinate (RightPoint) at (right.east);
}%
\draw[red,#2]
($(left)+(-\labelwidth,0.9em)$) rectangle
($(RightPoint)+(0.2em,-0.3em)$);}
}
\makeatother
\usepackage{pifont}
\newcommand{\titem}{\ding{226}\quad}
\usepackage{tabu}
%----------------------------------------------------------------------------------------
% TITLE PAGE
%----------------------------------------------------------------------------------------
\title[Lecture 2: Visualization and Programming]{Introduction to programming in MATLAB} % The short
\date{} % Date, can be changed to a custom date
\subtitle{Lecture 2: Visualization and Programming}
\begin{document}
% For every picture that defines or uses external nodes, you'll have to
% apply the 'remember picture' style. To avoid some typing, we'll apply
% the style to all pictures.
\tikzstyle{every picture}+=[remember picture]
\tikzstyle{na} = [baseline=-.5ex]
\begin{frame}{Surface Plots}
\begin{itemize}
\item It is more common to visualize surfaces in 3D
\item Example:
\begin{subequations}
\begin{empheq}[box=\widefbox]{align*}
&f(x,y)=sin(x)cos(y), \\
&x\in [-\pi , \pi]; y \in[-\pi ,\pi ]
\end{empheq}
\end{subequations}
\item \textcolor{orange}{\textbf{surf}} puts vertices at specified points in space x,y,z, and connects all the vertices to make a surface
\item The vertices can be denoted by matrices X\tikz \coordinate (s-mat); , Y\tikz[na] \coordinate (s-gray);, Z
\item How can we make these matrices\\
\parbox{.48\linewidth}{ %% <-----------------HERE
\begin{itemize}
\item loop (DUMB)
\item built-in function: \textcolor{orange}{\textbf{meshgrid}}
\end{itemize}
}
\hfill%
\parbox{.50\linewidth}{\hfill \tikzstyle{background grid}=[draw, black!50,step=.5cm]
\begin{tikzpicture}[show background grid]
\node[inner sep=0pt] (X) at (0,0) {\includegraphics[width=2cm]{example-image-a}};
\node [inner sep=0pt](Y) at (3,0){\includegraphics[width=2cm]{example-image-b}};
% show origin
%\fill (0,0) circle (2pt);
% define destination coordinates
\path (X) coordinate (mat)
(Y) coordinate (gray);
\end{tikzpicture}
}
\end{itemize}
\begin{tikzpicture}[overlay]
\path[->,black,thick] (s-mat.south) edge (mat.north);
\path[->,black,thick] (s-gray) edge (gray);
\end{tikzpicture}
\end{frame}
\end{document}