LaTeX에 GIF 삽입

LaTeX에 GIF 삽입

텍스트에 GIF 이미지를 삽입하고 싶은데 이것을 찾았습니다.즉시 GIF 이미지를 PNG로 변환.

그래서 문서에 붙여넣었습니다.

\documentclass[a4paper]{article}
\usepackage{graphicx}
\DeclareGraphicsRule{.JPG}{eps}{.JPG}{`convert #1 eps:-}
\begin{document}
\framebox{\includegraphics[0,0][150,200]{DSC00121-SMALL.JPG}}
\end{document} 

즉 나는

\usepackage{graphicx}
\DeclareGraphicsRule{.JPG}{eps}{.JPG}{`convert #1 eps:-}

그런 다음

 \framebox{\includegraphics[0,0][150,200]{nn.JPG}}

또한 사진의 이름을 다음과 같이 변경했습니다.nn.JPG

하지만 작동하지 않습니다! 도움이 필요하세요?

답변1

다음은 명령줄이 있다고 가정하는 pdfLaTeX의 MWE입니다.convert다음은 pdfLaTeX에 대한 MWE입니다. 다음 명령줄 이이미지 매직이미 PNG에 대한 방법이 있으므로 .png경로를 설치하고 사용합니다 .pdfLaTeX

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
% loading epstopdf package might be needed, 
% but is often automatically loaded by graphicx when running pdfLaTeX
%\usepackage{epstopdf}
% epstopdf setup for GIF
\DeclareGraphicsRule{.gif}{png}{.png}{%
  \noexpand\epstopdfcall{convert #1 \noexpand\OutputFile}%
}
\AppendGraphicsExtensions{.gif}

\begin{document}
\subsection*{This is a GIF version}
\includegraphics[width=0.5\linewidth]{tmp.gif}
% The GIF file is converted to tmp-gif-converted-to.png
\subsection*{This is a jpg version}
\includegraphics[width=0.5\linewidth]{tmp.jpg}
\subsection*{This is a png version}
\includegraphics[width=0.5\linewidth]{tmp.png}
\subsection*{This is a pdf version}
\includegraphics[width=0.5\linewidth]{tmp}
\end{document}

여기에 이미지 설명을 입력하세요

편집하다: 구식 LaTeX(dvi 모드)에서는 GIF를 EPS로 변환해야 합니다. 이를 위해 \DeclareGraphicsRule위의 내용을 다음으로 대체할 수 있습니다.

\DeclareGraphicsRule{.gif}{eps}{.gif.bb}{`convert #1 eps:-}

그런 다음 변환 명령이 파일에 그대로 기록되고 옵션 과 함께 실행되는 경우 .dvi에 의해 실행됩니다 . 마지막으로 를 사용하여 PDF 파일을 생성할 수 있습니다 .dvips-R0ps2pdf

그러나 이 방법에는 몇 가지 단점이 있습니다.

  • 변환된 수치는 엄청납니다.
  • 에서는 작동하지 않습니다 dvipdfm(x).
  • .gif.bb파일이 생성된 경우에만 작동하며 다음과 같은 명령을 사용하여 수행할 수 있습니다.identify tmp.gif |sed -r -e "s/(.*)\s+([0-9]{2,})x([0-9]{2,})\s+(.*)/%%BoundingBox: 0 0 \2 \3/" > tmp.gif.bb

각 그래픽 파일에 대해 tmp.gif.

이러한 맥락에서 적절한 옵션 또는 또는 (Windows에만 해당) 등을 LaTeX/dvips사용하여 외부의 모든 파일 변환을 수행하는 일괄 처리를 작성하는 것이 훨씬 더 효율적입니다 .convertNetpbmIrfanview

편집 2:Windows에서 이 convert명령은 디스크 처리 도구이며 최신 버전의 ImageMagick에서는 imagemagick convert기본 convert. 그런 다음 그에 \epstopdfcall따라 수정해야 합니다.

관련 정보