
我是 Tex 初學者,我有 tex 文件
\documentclass{article}
\addtolength{\jot}{1em}
\begin{document}
\begin{verbatim}
\end{verbatim}
\begin{chestnutStem}
In the following figure, if the spinner is divided into 8 colored sections, what is the probability of it stopping at blue?
\centerline{\includepdf[page=2]{mypdf.pdf}}
\end{chestnutStem}
\chestnutKey{
$ \frac{1}{4} $
}
\begin{chestnutAnswer}
\begin{align*}
\textrm{The probability of the spinner stopping at blue}&=\frac{\textrm{the number of blue sections}}{\textrm{total number of sections}}\\
&=\frac{2}{8}\\
&=\frac{1}{4}.
\end{align*}
\end{chestnutAnswer}
\end{document}
我有 cls 文件
\ProvidesClass{chestnut}[2016/02/17]
\LoadClass{article}
\RequirePackage{amsmath}
\RequirePackage{kvoptions}
\RequirePackage{graphicx}
\RequirePackage{xkeyval}
\DeclareStringOption{country}{}
\DeclareStringOption{language}{}
\DeclareStringOption{math}{}
\DeclareStringOption{numerals}{}
\ProcessKeyvalOptions*\relax
\DeclareOption{example}{%
\typeout{You are using example object.}
}%
\DeclareOption*{}{}
\ProcessOptions*\relax
\RequirePackage[lmargin=0.5in,rmargin=0.5in,tmargin=0.5in,bmargin=0.5in]{geometry}
\let\country=\chestnut@country
\typeout{ Your country \country}
\let\language=\chestnut@language
\typeout{ Your language \language}
\let\math=\chestnut@math
\typeout{ Your symbols language is \math}
\let\numerals = \chestnut@numerals
\typeout{ Your numerals are in \numerals}
\newenvironment{chestnutStem}{\underline{\textbf{Stem}}\\* }{\hfill \\* }
\newcommand\chestnutKey[1]{\underline{\textbf{Key}}\\*#1\hfill\\* }
\newenvironment{chestnutAnswer}{\underline{\textbf{Answer}}\\*}{\hfill \\* }
\RequirePackage{alternative4ht}
\altusepackage{pdfpages}
\newcommand\chestnutTikZ[1]{\includepdf[pages=-,width=.9\textwidth]{#1}}
\setlength{\parindent}{0pt}
\pagenumbering{gobble}
\IfFileExists{approved.jpg}{%
\RequirePackage{fancyhdr}
\renewcommand\headrule{}
\rhead{\vspace{0.5in}\includegraphics[scale=0.2]{approved.png}}
\pagestyle{fancy}
}%
和 Alternative4ht.sty 文件
\ProvidesPackage{alternative4ht}
\newcommand{\altusepackage}[2][]{%
\ifx\HCode\relax%
\usepackage[#1]{#2}%
\else%
\IfFileExists{#2-alt4ht.sty}{%
\usepackage[#1]{#2-alt4ht}%
}{\typeout{alternative4ht: no patch file for #2}}
\fi%
}
\endinput
和 pdfpages-alt4ht.sty 文件
\ProvidesPackage{pdfpages-alt4ht}
\RequirePackage{graphicx}
\newcommand\includepdf[2][]{%
\includegraphics{#2}
}
\endinput
和 cfg 檔案將 pdf 頁面轉換為 png 影像
\Preamble{xhtml}
\Configure{graphics*}
{pdf}
{\Needs{"convert -scene 1 \csname Gin@base\endcsname.pdf
\csname Gin@base\endcsname.png"}%
\Picture[pict]{\csname Gin@base\endcsname .png}% here i want add page number with pdf file name for example <mypdf-2.png>
\special{t4ht+@File: \csname Gin@base\endcsname.png}
}
\begin{document}
\EndPreamble
我想在命令中取得 [page] 值選項\includepdf
以在設定檔中使用它
答案1
pdfpages
tex4ht
是一旦包含就會導致失敗的軟體包之一。在這種情況下,必須更改 TeX 原始碼,這是我們在tex4ht
.helpers4ht 捆綁包提供\altusepackage
命令,可用於載入tex4ht
.這些替代包被命名為packagename-alt4ht.sty
.它們包含文件中使用的巨集的定義。的定義pdfpages
只是基本的,它只能用於包含一頁的 pdf 文件。
為了支援多頁 pdf 文件,我在套件中新增了命令pages
選項。它不支援原始的所有功能,因為實現它非常困難,而且我認為它在 HTML 輸出中沒有意義:\includepdf
pdfpages-alt4ht.sty
\ProvidesPackage{pdfpages-alt4ht}
\RequirePackage{graphicx}
\RequirePackage{xkeyval}
\define@key{includepdf}{pages}{\edef\current@pdf@page{\the\numexpr #1-1\relax}}
\newcommand\includepdf[2][]{%
\def\current@pdf@page{0}
\setkeys*{includepdf}{#1}
\filename@parse{#2}
\def\current@png@name{\filename@area\filename@base-\current@[email protected]}
\IfFileExists{\current@png@name}{}{%
\Needs{"convert #2[\current@pdf@page]
\current@png@name"}
}
\includegraphics{\current@png@name}
}
\endinput
它將請求的頁面保存在\current@pdf@page
巨集中,它必須減1,因為從0imagemagick
開始計數頁面。png
imagename-pagenumber.png
convert
我必須解決 中的一個問題,其中chestnut.cls
缺少:{}
IfFileExists
\ProvidesClass{chestnut}[2016/02/17]
\LoadClass{article}
\RequirePackage{amsmath}
\RequirePackage{kvoptions}
\RequirePackage{graphicx}
\RequirePackage{xkeyval}
\DeclareStringOption{country}{}
\DeclareStringOption{language}{}
\DeclareStringOption{math}{}
\DeclareStringOption{numerals}{}
\ProcessKeyvalOptions*\relax
\DeclareOption{example}{%
\typeout{You are using example object.}
}%
\DeclareOption*{}{}
\ProcessOptions*\relax
\RequirePackage[lmargin=0.5in,rmargin=0.5in,tmargin=0.5in,bmargin=0.5in]{geometry}
\let\country=\chestnut@country
\typeout{ Your country \country}
\let\language=\chestnut@language
\typeout{ Your language \language}
\let\math=\chestnut@math
\typeout{ Your symbols language is \math}
\let\numerals = \chestnut@numerals
\typeout{ Your numerals are in \numerals}
\newenvironment{chestnutStem}{\underline{\textbf{Stem}}\\* }{\hfill \\* }
\newcommand\chestnutKey[1]{\underline{\textbf{Key}}\\*#1\hfill\\* }
\newenvironment{chestnutAnswer}{\underline{\textbf{Answer}}\\*}{\hfill \\* }
\RequirePackage{alternative4ht}
\altusepackage{pdfpages}
\newcommand\chestnutTikZ[1]{\includepdf[pages=-,width=.9\textwidth]{#1}}
\setlength{\parindent}{0pt}
\pagenumbering{gobble}
\IfFileExists{approved.jpg}{%
\RequirePackage{fancyhdr}
\renewcommand\headrule{}
\rhead{\vspace{0.5in}\includegraphics[scale=0.2]{approved.png}}
\pagestyle{fancy}
}{}%
還有你的 TeX 文件,因為chestnut
沒有使用類別:
\documentclass{chestnut}
\addtolength{\jot}{1em}
\begin{document}
\begin{verbatim}
\end{verbatim}
\begin{chestnutStem}
In the following figure, if the spinner is divided into 8 colored sections, what is the probability of it stopping at blue?
\centerline{\includepdf[pages=2]{mypdf.pdf}}
\end{chestnutStem}
\chestnutKey{
$ \frac{1}{4} $
}
\begin{chestnutAnswer}
\begin{align*}
\textrm{The probability of the spinner stopping at blue}&=\frac{\textrm{the number of blue sections}}{\textrm{total number of sections}}\\
&=\frac{2}{8}\\
&=\frac{1}{4}.
\end{align*}
\end{chestnutAnswer}
\end{document}
範例輸出: