Получить ключевое значение команды

Получить ключевое значение команды

Я новичок в 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

Я хочу получить параметр значения [страница] в \includepdfкоманде, чтобы использовать его в файле конфигурации

решение1

pdfpagesодин из пакетов, который приводит tex4htк сбою после включения. В этом случае исходный код TeX должен быть изменен, чего мы пытаемся избежать с помощью tex4ht.пакет helpers4htпредоставляет \altusepackageкоманду, которая может быть использована для загрузки альтернативной версии пакетов для tex4ht. Эти альтернативные пакеты называются packagename-alt4ht.sty. Они содержат определения макросов, используемых в документе. Определение для pdfpagesбыло только базовым, его можно было использовать для включения только одного постраничного документа PDF.

Для поддержки многостраничных файлов pdf я добавил pagesопцию к \includepdfкоманде в pdfpages-alt4ht.styпакете. Она не поддерживает все функции оригинала, так как реализовать ее было бы довольно сложно, и я не думаю, что она имеет смысл в HTML-выводе:

\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, поскольку imagemagickотсчет страниц ведется с 0. 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} 

пример вывода:

введите описание изображения здесь

Связанный контент