LaTeX 中插入GIF图片

释放双眼,带上耳机,听听看~!

参见博文:liam.pagevoidcn

前提条件

  1. 安装 ImageMagick 软件 (因为要把 gif 图片转换成 png 序列),使用它的命令行工具 convert.exe
  2. 命令行下把 gif 转换成 png 序列,实际,例如 convert latex_demo.gif -coalesce output-pngs/latex_demo.png
  3. latex 源文件中引入宏包 animate
  4. 编写代码插入图片

需要注意的是,不是所有的PDF阅读器都能支持动画。

示例

第一步安装软件就不演示了,第二步转换图片序列,第三步、第四步的示例源码如下:

% !TEX TS-program = xelatex
% !TEX encoding = UTF-8

% This is a simple template for a XeLaTeX document using the \"article\" class,
% with the fontspec package to easily select fonts.

\\documentclass[11pt]{article} % use larger type; default would be 10pt

% 开启下面的设置可以插入中文
\\usepackage{ctex}
\\usepackage{color}

\\usepackage{fontspec} % Font selection for XeLaTeX; see fontspec.pdf for documentation
\\defaultfontfeatures{Mapping=tex-text} % to support TeX conventions like ``---\'\'
\\usepackage{xunicode} % Unicode support for LaTeX character names (accents, European chars, etc)
\\usepackage{xltxtra} % Extra customizations for XeLaTeX

%\\setmainfont{Charis SIL} % set the main body font (\\textrm), assumes Charis SIL is installed
%\\setsansfont{Deja Vu Sans}
%\\setmonofont{Deja Vu Mono}

% other LaTeX packages.....
\\usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots.
\\geometry{a4paper} % or letterpaper (US) or a5paper or....
%\\usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent

% support the \\includegraphics command and options
% PDF中插入GIF可以使用包 animate,前提是必须要先包含宏包 graphicx
\\usepackage{graphicx}
\\usepackage{animate}

\\title{PDF中插入GIF示例}
\\author{LinTeX9527}
\\date{\\today}
%\\date{} % Activate to display a given date or no date (if empty),
         % otherwise the current date is printed 

\\begin{document}
\\maketitle

\\begin{center}
    \\animategraphics[autoplay,
                    loop,
                    controls,
                    width=.7\\textwidth]{15}{./latex-pngs/latex_demo-}{0}{80}    
\\end{center}

\\end{document}

原始GIF图片如下

LaTeX 中插入GIF图片

PDF 中动图截图

LaTeX 中插入GIF图片

LaTeX 中插入GIF图片

LaTeX 中插入GIF图片

申明

欢迎转载,请注明出处和作者,同时保留声明。
作者:LinTeX9527
出处:https://www.cnblogs.com/LinTeX9527/p/11122268.html
本博客的文章如无特殊说明,均为原创,转载请注明出处。如未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利

给TA打赏
共{{data.count}}人
人已打赏
随笔日记

大白话5分钟带你走进人工智能-第30节集成学习之Boosting方式和Adaboost

2020-11-9 5:40:28

随笔日记

浅入深出Vue:数据绑定

2020-11-9 5:40:30

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索