LaTeX 中插入GIF圖片

參見博文:liam.pagevoidcnhtml

前提條件

  1. 安裝 ImageMagick 軟件 (由於要把 gif 圖片轉換成 png 序列),使用它的命令行工具 convert.exe
  2. 命令行下把 gif 轉換成 png 序列,實際,例如 convert latex_demo.gif -coalesce output-pngs/latex_demo.png
  3. latex 源文件中引入宏包 animate
  4. 編寫代碼插入圖片

須要注意的是,不是全部的PDF閱讀器都能支持動畫。app

示例

第一步安裝軟件就不演示了,第二步轉換圖片序列,第三步、第四步的示例源碼以下:工具

% !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圖片以下

PDF 中動圖截圖

申明

歡迎轉載,請註明出處和做者,同時保留聲明。
做者:LinTeX9527
出處:http://www.javashuo.com/article/p-vfkfgolq-gs.html
本博客的文章如無特殊說明,均爲原創,轉載請註明出處。如未經做者贊成必須保留此段聲明,且在文章頁面明顯位置給出原文鏈接,不然保留追究法律責任的權利oop

相關文章
相關標籤/搜索