我尝试用 png 图片编译我的 tex 文档。当我向 minipages 添加标题时,这会引发错误。如果我排除\caption*{#2}
和\caption*{}
编译成功。
我的代码:
\documentclass[12pt, twodise]{book}
\usepackage[polish, russian, english]{babel}
\usepackage[babel,autostyle=true]{csquotes}
\MakeOuterQuote{"}
\selectlanguage{english}
\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}
\usepackage{indentfirst}
\usepackage{needspace}
\usepackage{comment}
\usepackage[inner=0.75in, outer=0.75in, top=0.75in, bottom=0.75in, paperwidth=6in, paperheight=9in]{geometry}% inner=0.875in
%\usepackage{changepage}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{anyfontsize}
\usepackage{xargs}
\usepackage{epigraph}
\usepackage{afterpage}
\usepackage[figuresright]{rotating}
\usepackage{lettrine}
\usepackage{yfonts}
\usepackage{dpfloat}
\usepackage{nopageno}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage[font=Large,labelfont=Large]{caption}
\graphicspath{{"graphics/"}}
\DeclareGraphicsExtensions{.pdf,.png,.jpg}
\setlength{\parskip}{1em}
\newcommandx{\spic}[3][1=0,2]{
\clearpage
\noindent\begin{minipage}[t][\dimexpr\textheight-6pt\relax][c]{\textwidth}
\centering\includegraphics[angle=#1, width=\textwidth]{#3}
%\caption*{#2}
\end{minipage}
\clearpage
}
\newcommandx{\pic}[3][1=0,2]{
\begingroup
\clearpage
\newpage
\vspace*{3in}
\centering{\Large #2}
\newpage
\begin{minipage}[t][\dimexpr\textheight-6pt\relax][c]{\textwidth}
\center{\includegraphics[angle=#1, width=\textwidth]{#3}}
%\caption*{#2}
\end{minipage}
\clearpage
\endgroup
}
\newcommandx{\lpic}[3][1=0, 2=]{
\newpage
% \clearpage
% \thispagestyle{empty}
\begin{sidewaysfigure}[ht]
\center{\includegraphics[angle=#1, width=0.8\textheight]{#3}}
\caption*{#2}
\end{sidewaysfigure}
}
\newcommand\blankpage{
\null
%\thispagestyle{empty}
%\addtocounter{page}{-1}
\newpage
}
\newcommand{\tmpx}{}
\newcommand\tmp[1]{\renewcommand{\tmpx}{#1}}
\fancypagestyle{capt}{\fancyfoot[R]{\tmpx}}
\newcommandx{\twosidepic}[2][2]{
\clearpage
\begingroup
\sbox0{\includegraphics{#1}}
\begin{figure}[p]% will be the left-side figure
\begin{leftfullpage}
\noindent\begin{minipage}[t][\textheight][c]{\paperwidth}
\hspace*{-2\leftmargin}
\includegraphics[trim=0 0 {.5\wd0} 0,width=\dimexpr\paperwidth\relax,clip]{#1}
\captionsetup{font = Large, labelfont=Large, singlelinecheck = false, format= hang, justification=raggedleft, labelsep=space}
% --------------PROBLEM IS HERE !!! ----------------------------------------------
% \caption*{}
\end{minipage}
\end{leftfullpage}
\end{figure}
\begin{figure}[p]
\begin{fullpage}
\noindent\begin{minipage}[t][\textheight][c]{\paperwidth}
\hspace*{-2\leftmargin}
\includegraphics[trim={.5\wd0} 0 0 0,width=\dimexpr\paperwidth\relax,clip]{#1}
\captionsetup{font = Large, labelfont=Large, singlelinecheck = false, format= hang, labelsep=space, justification=centering} %justification=justified
% --------------PROBLEM IS HERE !!! ----------------------------------------------
% \caption*{#2}
%
\end{minipage}
\end{fullpage}
\end{figure}
\endgroup
}
% \pagestyle{fancy}
\fancyhf{}
\fancypagestyle{alim}{\fancyhf{}\renewcommand{\headrulewidth}{0pt}\fancyfoot[C]{\arabic{page}}}
\addto\captionsenglish{\renewcommand{\figurename}{}}
\begin{document}
\pic{_SDC2222}
\twosidepic{_SDC3333}
%\end{comment}
\end{document}
答案1
即使使用,我也无法编译您的示例pdflatex
,它会失败并显示以下消息:
dpfloat moved a leftpage float from page 3. ! Output loop---100
consecutive dead cycles. \AP@clearpage ...e \m@ne {}\vbox {}\penalty
-\@Mi
因此我创建了一个更简单的例子来展示同样的问题:
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\begin{document}
\begin{figure}
\includegraphics{example-image.png}
\captionsetup{font = Large, labelfont=Large, singlelinecheck = false, format= hang, labelsep=space, justification=centering} %justification=justified
\caption*{Hello, caption}
\end{figure}
\end{document}
此文件导致 TeX4ht 失败。要修复此问题,我们需要更新两个支持文件。
第一个是usepackage.4ht
。此文件用于在加载软件包时对其进行修补:
% usepackage.4ht (2020-04-23-13:56), generated from tex4ht-4ht.tex
% Copyright 2003-2009 Eitan M. Gurari
% Copyright 2009-2020 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2020-04-23-13:56}
\def\:temp{tex4ht}\ifx \:temp\@currname
\:warning{\string\usepackage{tex4ht} again?}
\def\:temp#1htex4ht.def,tex4ht.sty#2!*?: {\def\:temp{#2}}
\expandafter\:temp \@filelist htex4ht.def,tex4ht.sty!*?: %
\ifx \:temp\empty \else
\:warning{if
\string\RequirePackage[tex4ht]{hyperref} or
\string\usepackage[tex4ht]{hyperref} was
used try instead, repectively,
\string\RequirePackage{hyperref} or
\string\usepackage{hyperref}}
\fi
\fi
\gdef\a:usepackage{\use:package cleveref,xr,xr-hyper,eso-pic,showframe,expl3,savetrees,biblatex,xeCJK,polyglossia,fontspec,tikz,pdfbase,caption,graphics,xcolor,imakeidx,minted,fancyhdr,,!*?: }
\gdef\use:package#1,{%
\if :#1:\def\:temp##1!*?: {}\else
\def\:temp{#1}\ifx \@currname\:temp
\def\:temp##1!*?: {\input usepackage.4ht }%
\else \let\:temp=\use:package \fi
\fi \:temp}
\def\:temp{cleveref}\ifx\@currname\:temp
\let\HyOrg@addtoreset\@addtoreset
\fi
\def\:temp{xr}\ifx \@currname\:temp
\:AtEndOfPackage{\let\XR:\XR@
\def\XR@[#1]#2{%
\Configure{AtBeginDocument}{\XR:[#1]{#2}}{}}%
}
\fi
\def\:temp{xr-hyper}\ifx \@currname\:temp
\:AtEndOfPackage{\let\XR:\XR@
\def\XR@[#1][#2]#3{%
\AtBeginDocument{\XR:[#1][#2]{#3}}
}%
}
\fi
\def\:temp{eso-pic}\ifx \@currname\:temp
\:dontusepackage{eso-pic}
\newcommand\AddToShipoutPicture{\@ifstar{}{}}
\let\AddToShipoutPictureBG\AddToShipoutPicture
\let\AddToShipoutPictureFG\AddToShipoutPicture
\fi
\def\:temp{showframe}\ifx \@currname\:temp
\:dontusepackage{showframe}
\fi
\def\:temp{expl3}\ifx \@currname\:temp
\ifdefined\XeTeXversion%
\xenunidelblock{Latin-expl3}%
\:AtEndOfPackage{\xeuniuseblock{Latin-expl3}}
\fi
\fi
\def\:temp{savetrees}\ifx \@currname\:temp
\:dontusepackage{savetrees}
\fi
\def\:temp{biblatex}\ifx \@currname\:temp
\:AtEndOfPackage{%
\def\blx@mknoautolang{%
\blx@lbxinput{\blx@languagename}%
{}{}%
}%
\def\blx@lbxinput@iii#1#2{%
\global\csundef{blx@lng@#2}%
\:IfFileExists{#1.lbx}
{\blx@lbxinput@iv{#2}{#1}{language '#2' -> '#1'}}
{\ifcsdef{blx@suffmaptried@#2}
{}
{\blx@warning@noline{%
File '#1.lbx' not found!\MessageBreak
Ignoring mapping '#2' -> '#1'}%
\global\cslet{blx@suffmaptried@#2}\@empty}%
\blx@lbxinput@iv{#2}{#2}{language '#2'}}}
}
\fi
\def\:temp{xeCJK}\ifx \@currname\:temp
\:dontusepackage{xeCJK}
\:AtEndOfPackage{%
\RequirePackage{fontspec}
}
\DeclareDocumentCommand\setCJKmainfont{o m o}{}
\let\setCJKsansfont\setCJKmainfont
\let\setCJKmonofont\setCJKmainfont
\DeclareDocumentCommand\setCJKfamilyfont {m o m }{}
\DeclareDocumentCommand\newCJKfontfamily {o m o m}{\expandafter\gdef\csname #2\endcsname{\relax}}
\DeclareDocumentCommand\xeCJKsetup{m}{}
% }
\AtBeginDocument{%
\xeuniuseblock{CJK}
}
\fi
\def\:temp{polyglossia}\ifx \@currname\:temp
\ExplSyntaxOn
\:AtEndOfPackage{
\cs_set_eq:NN\orig_polyglossia@keys_define_lang:n\polyglossia@keys_define_lang:n
\cs_set_protected:Npn \polyglossia@keys_define_lang:n #1 {
\orig_polyglossia@keys_define_lang:n{#1}
\keys_define:nn {polyglossia}{
#1 / direction
. code:n = {}
}
}
\def\RequireBidi{}%
}
\ExplSyntaxOff
\fi
\def\:temp{fontspec}\ifx \@currname\:temp
\ifdefined\fontspec
\:dontusepackage{fontspec}
\else
\input usepackage-fontspec.4ht
\fi
\fi
\def\:temp{tikz}\ifx \@currname\:temp
\:AtEndOfPackage{%
\let\use:tikzlibrary\usetikzlibrary
\def\find:externalize#1external#2\@nil{%
\if\relax#2\relax\else
\let\tikz:externalize\tikzexternalize
\renewcommand\tikzexternalize[1][]{\tikz:externalize[##1,mode=only graphics]}
\tikzset{%
tex4ht inc/.style={%
/pgf/images/include external/.code={%
\includegraphics[]{####1.pdf}%
}%
}
}
\tikzset{tex4ht inc}
\fi
}
\append:defI\use@@tikzlibrary{\find:externalize##1external\@nil}%
}
\fi
\def\:temp{pdfbase}\ifx\@currname\:temp
\:AtEndOfPackage{%
\let\old:outputpage\@outputpage
\def\@outputpage{\old:outputpage{}}
}
\fi
\def\:temp{caption}\ifx\@currname\:temp
\:AtEndOfPackage{%
\long\def\caption@If@Package@Loaded#1[#2]#3#4{}
%\renewcommand*\caption@redefine{}
\renewcommand*\caption@redefine{%
\let\caption\caption@caption
\let\@caption\caption@@caption%
}%
}
\fi
\def\:temp{graphics}\ifx\@currname\:temp
\ifdefined\XeTeXversion
\PassOptionsToPackage{dvips}{graphics}
\fi
\fi
\def\:temp{xcolor}\ifx\@currname\:temp
\ifdefined\XeTeXversion
\PassOptionsToPackage{dvips}{xcolor}
\fi
\fi
\def\:temp{imakeidx}\ifx\@currname\:temp
\PassOptionsToPackage{noautomatic}{imakeidx}
\fi
\def\:temp{minted}\ifx\@currname\:temp
\:AtEndOfPackage{%
\define@booleankey{minted@opt@g}{breaklines}{}{}{}%
}
\fi
\def\:temp{fancyhdr}\ifx\@currname\:temp
\:AtEndOfPackage{%
\def\ps@fancy{}%
}
\fi
\endinput
重要的部分是这样的:
\def\:temp{caption}\ifx\@currname\:temp
\:AtEndOfPackage{%
\long\def\caption@If@Package@Loaded#1[#2]#3#4{}
\renewcommand*\caption@redefine{%
\let\caption\caption@caption
\let\@caption\caption@@caption%
}%
}
\fi
这修复了致命错误。
接下来,我们需要提供定制的定义来正确支持带星号的命令版本\caption
。
另存为caption.4ht
:
% caption.4ht (2020-05-22-14:40), generated from tex4ht-4ht.tex
% Copyright 2007-2009 Eitan M. Gurari
% Copyright 2009-2020 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\let\sv:toclof\toclof
\def\toclof#1#2#3{%
\bgroup
\def\a:TocLink##1##2##3##4{\gdef\:temp{##4}}%
#2%
\egroup
\ifx \:temp\empty \else
\sv:toclof{#1}{#2}{#3}%
\fi
}
\let\lof:ConfigureToc\ConfigureToc
\long\def\ConfigureToc#1#2#3#4#5{%
\lof:ConfigureToc{#1}{#2}{#3}{#4}{#5}%
\def\:temp{#1}\def\:tempa{lof}\ifx \:temp\:tempa
\let\toc:lof\toclof
\def\toclof##1##2##3{%
\bgroup
\def\a:TocLink####1####2####3####4{\gdef\:temp{####4}}%
##2%
\egroup
\ifx\:temp\empty\else
\toc:lof {##1}{##2}{##3}%
\fi
}\fi%
}
\long\def\@makecaption#1#2{%
\caption@make@above%
\cptA:\caption@@make{\cap:ref{#1}\if :#1:\else\cptB:\fi}{\cptC:#2}\cptD:%
\caption@make@below%
}
\Hinput{caption}
\endinput
它包含命令的修改版本\@makecaption
:
\long\def\@makecaption#1#2{%
\caption@make@above%
\cptA:\caption@@make{\cap:ref{#1}\if :#1:\else\cptB:\fi}{\cptC:#2}\cptD:%
\caption@make@below%
}
\cptA:
和其他名称中包含字符的命令用于:
插入 HTML 标签。
结果如下:
这些文件也适用于您的原始文件,但我无法判断结果是否正确,因为我无法编译 PDF 版本。