TransWikia.com

Move tables and figures to the end of a section/chapter

TeX - LaTeX Asked by Rodrigo Pacheco on April 3, 2021

I am looking for a way to customize the position of the figures/tables of my document.
Is there a way to move the figures/tables to the end of each section of the document?
Thanks

One Answer

One posibility is to us a stack-like system.

usepackage{etoolbox}
makeatletter
% Define a new stack by letting it to @empty
newcommandnewStack[1]{globallet#1@empty}
% add element to stack (top): addStack{<stack>}{<element>}
newcommandaddStack[2]{defele@ment{{#2} }xdef#1{ele@ment #1}}
% add element to stack (bottom) revaddStack{<stack>}{<element>}
newcommandrevaddStack[2]{defele@ment{{#2} }xdef#1{#1 ele@ment}}

% remove from stack
longdefpop@#1 #2@nil#3{defpopedStackElement{#1}%
  def#3{#2}}% remaining list
% stack name #1
newcommandpopStack[1]{letpopedStackElement@empty%
ifx #1@emptymessage{LaTeX warning: you are trying to remove an element from the empty stack noexpand#1 on input line theinputlineno}elseexpandafterpop@#1@nil#1fi}
% whipe stack
newcommandcleanStack[1]{globallet#1@empty}
makeatother

Depending on how complicate your floats are it is probably a good idea to put them in one file each and append them with something like

newcommand{printfloats}{begingroup%
  defdo##1{input{##1}}%
    dolistloop{myfloatsattheend}%
  endgroup}

which would require something like

newStack{myfloatsattheend}

[some text]

revaddstack{myfloatsattheend}{<floatsfilename1>}

[some text]

revaddstack{myfloatsattheend}{<floatsfilename2>}

and at the end of the section

printfloats
cleanStack{myfloatsattheend}

Answered by AndiW on April 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP