我正在寻找一种方法来自定义文档中图表/表格的位置。有没有办法将图表/表格移动到文档每个部分的末尾?谢谢
答案1
一种可能性就是我们使用类似堆栈的系统。
\usepackage{etoolbox}
\makeatletter
% Define a new stack by letting it to \@empty
\newcommand\newStack[1]{\global\let#1\@empty}
% add element to stack (top): \addStack{<stack>}{<element>}
\newcommand\addStack[2]{\def\ele@ment{{#2} }\xdef#1{\ele@ment #1}}
% add element to stack (bottom) \revaddStack{<stack>}{<element>}
\newcommand\revaddStack[2]{\def\ele@ment{{#2} }\xdef#1{#1 \ele@ment}}
% remove from stack
\long\def\pop@#1 #2\@nil#3{\def\popedStackElement{#1}%
\def#3{#2}}% remaining list
% stack name #1
\newcommand\popStack[1]{\let\popedStackElement\@empty%
\ifx #1\@empty\message{LaTeX warning: you are trying to remove an element from the empty stack \noexpand#1 on input line \the\inputlineno}\else\expandafter\pop@#1\@nil#1\fi}
% whipe stack
\newcommand\cleanStack[1]{\global\let#1\@empty}
\makeatother
根据你的浮点数的复杂程度,最好将它们放在一个文件中,然后添加类似
\newcommand{\printfloats}{\begingroup%
\def\do##1{\input{##1}}%
\dolistloop{\myfloatsattheend}%
\endgroup}
这将需要类似
\newStack{\myfloatsattheend}
[some text]
\revaddstack{\myfloatsattheend}{<floatsfilename1>}
[some text]
\revaddstack{\myfloatsattheend}{<floatsfilename2>}
并在本节末尾
\printfloats
\cleanStack{\myfloatsattheend}