latex
中在确定的位置放置对象,诀窍是使用图片环境,然后给对象提供坐标。可以使用LaTeX2e
自带的picture
环境,也可以使用专门的tikz
包提供的tikzpicture
环境。参考下面的链接:
How to position images in Beamer absolutely
Precise positioning in LaTeX beamer
lshort Page89
picture 环境
基于对LaTeXpicture
环境的巧妙使用,将每张幻灯片变成一幅大图,在其中可以使用坐标来放置公式,文本,图像或视频。
举个例子。使用的图像文件在blogs.helsinki.fi。
\documentclass[graphics]{beamer}
\begin{document}
\begin{frame}{Drawing the unit disc is a good way to introduce sine and cosine functions}
\begin{picture}(320,250)
\put(-80,20){\includegraphics[height=8cm]{sincos2.png}}
\put(180,180){\begin{minipage}[t]{0.4\linewidth}
{Choose a point on the unit circle. Connect it to the origin with a line of length one, and denote the angle between that line and the horizontal coordinate axis by $\theta$.}
\end{minipage}}
\end{picture}
\end{frame}
\end{document}
这是生成的幻灯片:
img现在,我们创建两张连续的幻灯片,并包含一些新结构。
\documentclass[graphics]{beamer}
\begin{document}
\begin{frame}{Drawing the unit disc is a good way to introduce sine and cosine functions}
\begin{picture}(320,250)
\put(-80,20){\includegraphics[height=8cm]{sincos2.png}}
\put(180,180){\begin{minipage}[t]{0.4\linewidth}
{Choose a point on the unit circle. Connect it to the origin with a line of length one, and denote the angle between that line and the horizontal coordinate axis by $\theta$.}
\end{minipage}}
\end{picture}
\end{frame}
\begin{frame}{Now sine and cosine of angle $\theta$ can be found as the $x$ and $y$ coordinates of the chosen point at the unit circle}
\begin{picture}(320,250)
\put(-80,20){\includegraphics[height=8cm]{sincos3.png}}
\put(180,180){\begin{minipage}[t]{0.4\linewidth}
{Try drawing a similar figure with larger values of $\theta$. What happens to sine and cosine when you complete a full circle? Can you see from the figure which one of the functions $\sin$ and $\cos$ is odd and which one is even?}
\end{minipage}}
\end{picture}
\end{frame}
\end{document}
产生的两张幻灯片如下所示:
imgimg
请注意,圆的位置没有移动。切换幻灯片时,彩色部分将覆盖在上一张图像上。
上述方法仍然存在一个问题。如果某一页标题较长,超过下一页,则图片环境的位置将发生改变,失去连续幻灯片切换时的平稳覆盖效果。解决方法是在标题较短的那一张添加额外的ghost
行:
\begin{frame}{Too short title\\ \phantom{m}}
参考lshort
,picture
环境的语法如下:
\begin{picture}(width,height)...\end{picture}
%% 或者是
\begin{picture}(width,height)(x0;y0)...\end{picture}
x,y,x0,y0
的单位是\unitlength
, 默认是1pt
. 可以随时使用命令重置,比如\setlength{\unitlength}{1.2cm}
,但要在picture
环境之外.
前一组坐标(width,height)
指定矩形的大小,后一组(x0;y0)
指定矩阵左下角,即锚点的位置。
大部分画图指定的形式为
\put(x;y){object}
%% 或者
\multiput(x;y)(∆x;∆y){n}{object}
一个简单的例子:
\setlength{\unitlength}{5cm}
\begin{picture}(1,1)
\put(0,0){\line(0,1){1}}
\put(0,0){\line(1,0){1}}
\put(0,0){\line(1,1){1}}
\put(0,0){\line(1,2){.5}}
\end{picture}
tikz 环境
如果比较复杂的情况,使用tikz
会更简单,且有更多的功能.
\tikz[remember picture, overlay] \node[anchor=center] at (current page.center) {\includegraphics{foo}};
编译两次得到输出,图片恰好放置在幻灯片的中心。 可以更改锚点以移动图片,并且可以使用calc
库进行进一步的调整。
% 导言区
\usepackage{tikz}
\usetikzlibrary{calc}
% 主文档
\tikz[remember picture, overlay] \node[anchor=center] at ($(current page.center)-(1,0)$) {\includegraphics{foo}};
图像将被放置在中心左侧1
厘米处。
参考beamer中任意摆放图片的方法. 也可以使用下面的语法:
\begin{tikzpicture}[remember picture,overlay]
\node<1->[xshift=-3cm,yshift=-1cm] at (current page.center) {\includegraphics[height=3cm]{fig}};
\node<2->[xshift=0cm,yshift=0cm] at (current page.center) {\includegraphics[height=3cm]{fig}};
\node<3->[xshift=3cm,yshift=1cm] at (current page.center) {\includegraphics[height=3cm]{fig}};
\end{tikzpicture}
texdoc tikz
文档 p.238 关于位置库的说明。 常用的位置有:
center, north west, west, north, base, north east, east
网友评论