
기본적으로 중간에 중앙에 그래프가 있는 일부 텍스트인 간단한 LaTeX 코드 조각을 변환하고 싶습니다. 이것은 HTML로 변환하려는 코드의 더미 버전입니다.
\documentclass{article}
\usepackage{lmodern}
\usepackage{pgfplots}
\usepackage{lipsum}
\pgfplotsset{compat=1.9}
\begin{document}
\lipsum
\begin{center}
\begin{tikzpicture}
\begin{axis}[
ybar stacked,
ymin=0, ymax=35,
width=9cm,
height=6cm,
symbolic x coords={Zimbabwe, France, Italy, Kenya, Germany},
xtick=data,
bar width=15pt,
axis lines*=left,
ytick={0,5,...,35},
xticklabel style={
text height=1.5ex,font=\footnotesize
},
yticklabel style={
font=\footnotesize
},
ymajorgrids,
xlabel={ ... ... ... ... ... , 2004-2009},
xlabel style={yshift=5.8cm,xshift=.9cm},
]
\addplot[fill=gray!50] coordinates {
(Zimbabwe,16)
(France,30)
(Italy,10)
(Kenya,5)
(Germany,20)
};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
latex4ht
예전에 사용하던 을 사용하는데 지 쳤는데 , PGFplot 코드에서는 작동하지 않는 것 같습니다.
그래서 제 질문은: PGFplot 그래프를 html로 어떻게 변환합니까? 당신의 도움을 주셔서 감사합니다
답변1
tikz
및 를 사용하여 html 및 svg 그래픽을 얻는 방법에는 여러 가지가 있습니다 tex4ht
. 제 생각에는 가장 좋은 방법은 라이브러리를 사용하여 tikz externalization
변환을 수행하는 것입니다. 이 라이브러리를 사용하면 pdf
모든 사진에 대해 독립 실행형 이미지가 생성되고 tikz
일부 외부 명령을 사용하여 이 pdf
이미지를 svg
. 나는 inkscape
이 작업을 다른 응용 프로그램과 함께 수행하면서 큰 성공을 거두었습니다 . imagemagick
몇 가지 문제를 발견했지만 결과가 정확하지 않았습니다. 따라서 inkscape
이 작업을 수행하려면 설치가 필요합니다 .
externalization
먼저 다음과 같이 설정할 패키지를 만듭니다 myexternalize.sty
.
\usetikzlibrary{external}
\tikzset{
tex4ht inc/.style={
/pgf/images/include external/.code={%
\includegraphics[]{##1.svg}%
}
}
}
\tikzset{
external/system call/.add={}
{; inkscape -z -f "\image.pdf" -l "\image.svg"
}
}
\@ifpackageloaded{tex4ht}{
\tikzexternalize[mode=only graphics]
\tikzset{tex4ht inc}
}{
\tikzexternalize
}
이 패키지는 와 함께 사용될 새로운 tikz
스타일을 생성합니다 . 를 사용하면 파일 을 내보내고 명령줄 모드에서 호출하여 이 이미지를 .tex4ht inc
tex4ht
pdflatex
pdf
inscape
pdf
svg
이제 이미지, 파일을 tex4ht
포함할 수 있도록 몇 가지 구성이 필요합니다 .svg
myexternalize.4ht
\Configure{graphics*}
{svg}{
{\Configure{Needs}{File: \[email protected]}\Needs{}}
\Picture[\csname a:GraphicsAlt\endcsname]{\csname Gin@base\endcsname.svg \csname a:Gin-dim\endcsname}%
}
이제 myexternalize
문서에 패키지를 포함할 수 있습니다.
\documentclass{article}
\usepackage{lmodern}
\usepackage{pgfplots}
\usepackage{lipsum}
\pgfplotsset{compat=1.9}
\usepackage{myexternalize}
....
그런 다음 문서를 다음과 같이 컴파일하십시오.
pdflatex -shell-escape documentname
파일을 얻으려면 svg
. -shell-escape
옵션이 중요합니다. 그렇지 않으면 변환이 작동하지 않습니다! 이제 파일을 html로 컴파일할 수 있습니다.
htlatex documentname
결과를 볼 수 있어요여기