目前.tex
文档里\include
了.cls
文件,.cls
文件里对图表格式进行了定义,要求只在文末列表汇总显示。
求教需求:修改.cls
相关代码,实现图表既在正文提及处显示,又在文末列表汇总显示。
.cls
当前相关代码如下:
\newboolean{BackFigs}
\newboolean{InsideFigs}
\DeclareOption{BackFigs}%
{\setboolean{BackFigs}{true}\setboolean{InsideFigs}{false}}
\DeclareOption{InsideFigs}%
{\setboolean{InsideFigs}{true}\setboolean{BackFigs}{false}}
\ifthenelse{\boolean{Journal}}
{\ifthenelse{\boolean{InsideFigs}}{true}{\setboolean{BackFigs}{true}}}
{\ifthenelse{\boolean{BackFigs}}{true}{\setboolean{InsideFigs}{true}}}
\ifthenelse{\boolean{BackFigs}}
{\typeout{%
(2) Figures and Tables will be placed together at the end of the manuscript
(change with the 'InsideFigs' option)}}
{\typeout{%
(2) Figures and Tables will be placed within the text of the manuscript
(change with the 'BackFigs' option)}}
\ifthenelse{\boolean{BackFigs}}
{\ifthenelse{\boolean{NoLists}}% 11-21-02
{\RequirePackage[nolists,noheads,nomarkers,tablesfirst]{endfloat}}%11-21-02
{\RequirePackage[lists,noheads,nomarkers,tablesfirst]{endfloat}}
}
\ifthenelse{\boolean{Journal}\and\boolean{BackFigs}}%
{\setlength{\Abovecaptionrule}{0.75in}}
{\setlength{\Abovecaptionrule}{0.05in}}
\ifthenelse{\boolean{BackFigs}}
{\renewcommand\listoftables{%
\section*{\listtablename
\@mkboth{%
\MakeUppercase\listtablename}{\MakeUppercase\listtablename}}%
\ifthenelse{\boolean{DoubleSpace}}% 02-14-13
{\doublespacing\@starttoc{lot}\singlespacing}% 02-14-13
{\@starttoc{lot}}}
\renewcommand\listoffigures{%
\section*{\listfigurename
\@mkboth{\MakeUppercase\listfigurename}%
{\MakeUppercase\listfigurename}}%
\ifthenelse{\boolean{DoubleSpace}}% 02-14-13
{\doublespacing\@starttoc{lof}\singlespacing}% 02-14-13
{\@starttoc{lof}}}
}{}
考古... 你提及:
实现图表既在正文提及处显示,又在文末列表汇总显示
egreg在此处使用寄存器保存figure
中的信息,并在文末重新输出:
下面是一个例子:
\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{environ}
\makeatletter
\let\@@figure\figure
\let\@@endfigure\endfigure
\let\figure\@undefined
\let\endfigure\@undefined
\let\@@table\table
\let\@@endtable\endtable
\let\table\@undefined
\let\endtable\@undefined
\newtoks\end@figuretoks
\newtoks\end@tabletoks
\NewEnviron{figure}[1][htp]{%
\@@figure[#1]\BODY\@@endfigure
\global\end@figuretoks=\expandafter{\the\end@figuretoks\@@figure[p]}%
\global\end@figuretoks=\expandafter{\the\expandafter\end@figuretoks\BODY\@@endfigure}%
}
\NewEnviron{table}[1][htp]{%
\@@table[#1]\BODY\@@endtable
\global\end@tabletoks=\expandafter{\the\end@tabletoks\@@table[p]}%
\global\end@tabletoks=\expandafter{\the\expandafter\end@tabletoks\BODY\@@endtable}%
}
\newcounter{Endfigure}
\AtEndDocument{\clearpage\let\c@figure\c@Endfigure\the\end@figuretoks}
\newcounter{Endtable}
\AtEndDocument{\clearpage\let\c@table\c@Endtable\the\end@tabletoks}
\makeatother
\usepackage{lipsum}
\begin{document}
\lipsum
\begin{figure}
\centering
\includegraphics{example-image-a}
\caption{def}
\end{figure}
\lipsum
\begin{figure}
\centering
\includegraphics{example-image-b}
\caption{def}
\end{figure}
\lipsum
\begin{figure}
\centering
\includegraphics{example-image-c}
\caption{def}
\end{figure}
\lipsum
\begin{table}
\centering
\begin{tabular}
{ | c | c | c | }
\hline
Column 1 & Column 2 & Column 3 \\
\hline
Row 1 & Row 1 & Row 1 \\
Row 2 & Row 2 & Row 2 \\
Row 3 & Row 3 & Row 3 \\
\hline
\end{tabular}
\caption{table1}
\end{table}
\lipsum
\begin{table}
\centering
\begin{tabular}
{ | c | c | c | }
\hline
Column 1 & Column 2 & Column 3 \\
\hline
Row 1 & Row 1 & Row 1 \\
Row 2 & Row 2 & Row 2 \\
Row 3 & Row 3 & Row 3 \\
\hline
\end{tabular}
\caption{table2}
\end{table}
\end{document}
BTW...如非必要,不要修改模板。除非你是模板作者...那也不应该问出这样子的问题,应该自行提取MWE再提问...