美文网首页
beamer 在确定的位置摆放图片

beamer 在确定的位置摆放图片

作者: Gravition | 来源:发表于2021-04-29 04:04 被阅读0次

latex中在确定的位置放置对象,诀窍是使用图片环境,然后给对象提供坐标。可以使用LaTeX2e自带的picture环境,也可以使用专门的tikz包提供的tikzpicture环境。参考下面的链接:

How to position images in Beamer absolutely
Precise positioning in LaTeX beamer
lshort Page89

picture 环境

基于对LaTeXpicture环境的巧妙使用,将每张幻灯片变成一幅大图,在其中可以使用坐标来放置公式,文本,图像或视频。

举个例子。使用的图像文件在blogs.helsinki.fi

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}
\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}

产生的两张幻灯片如下所示:

img
img

请注意,圆的位置没有移动。切换幻灯片时,彩色部分将覆盖在上一张图像上。

上述方法仍然存在一个问题。如果某一页标题较长,超过下一页,则图片环境的位置将发生改变,失去连续幻灯片切换时的平稳覆盖效果。解决方法是在标题较短的那一张添加额外的ghost行:

\begin{frame}{Too short title\\ \phantom{m}}

参考lshortpicture环境的语法如下:

\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

相关文章

  • beamer 在确定的位置摆放图片

    latex中在确定的位置放置对象,诀窍是使用图片环境,然后给对象提供坐标。可以使用LaTeX2e自带的pictur...

  • 分层定物A-确定物品最佳摆放位置《4T现场管理培训》

    分层定物A-确定物品最佳摆放位置《4T现场管理培训》 确定物品最佳摆放位置 搬运更短的距离 花费更少的时间 消耗更...

  • jquery 瀑布流

    瀑布流布局的特点: 【1】展示的图片元素都是等宽不等高,图片的位置用position:absolute定位来摆放。...

  • 2019-01-20

    图片的大小,摆放的位置都可以改变。 视频的大小可以改变。 问题:图片和视频放在什么地方?

  • Android布局的介绍

    概念 布局:界面控件摆放位置的确定。 所有的布局都继承ViewGroup 在Android4.0以前一共有五种布局...

  • 聚宝盆摆放位置

    1.摆放到财位 在财位这个地方摆放聚宝盆是最合适的,不管是明财位还是暗财位,本身都是财气聚集的地方,只要在这个地方...

  • 无主灯设计学习记录

    1、分析整体空间功能,建筑特色,视觉作业,设计风格,家具位置,物件摆放,氛围需求,确定灯光位置。 2、设置优先级,...

  • 神位的摆放位置

    一般来说,家中的神位最好就是摆放在吉方,这个吉方可以是住宅点吉方,也可以是自己本命的吉方。一般来说,把神位摆放在吉...

  • iOS-button标题和图片位置的摆放

    项目中我们经常会有这样的需求,button中图片左标题右,图片上标图下,图片下标题上,图片右标题左;感觉挺简单的是...

  • view绘制:layout布局阶段&FrameLayout

    Layout阶段主要根据得到View的测量的宽高来确定我们View最终摆放的位置 View --- > Layou...

网友评论

      本文标题:beamer 在确定的位置摆放图片

      本文链接:https://www.haomeiwen.com/subject/rmlirltx.html