Is it possible to include the whole content of the table and figure in another tex file?

Let's say we have A.tex


write something here.

            {test} & {test} & {test} & {test} \\
            {test} & {test} & {test} & {test} \\



And I want to include the tab:test and fig:test in B.tex with the following code:


This only get the index of the table and figure like Tab. 2 and Fig. 10. Is it able to import both the contents and the indexes of the table and fig in B.tex? That is, the indexes should still be the same as those A.tex.

  • xr "[...] implements a system for eXternal References" nothing more nothing less. If you want to have the code in your document, you have to copy it in or do some gymnastics
    – DG'
    Mar 8, 2023 at 8:53
  • 1
    One way to do this is by saving your table and figure in separate .tex files and using \input{yourtable} or \input{yourfigure} in your main .tex file. Is this what you were looking for?
    – scd
    Mar 8, 2023 at 11:23
  • @DG' Got it. I'll have a look at the link. Thanks for your kind help.
    – yangtzech
    Mar 8, 2023 at 12:31
  • @scd \input{the figure tex file} results in different indexes for the figure. However, I am writing B.tex (a report) based on A.tex by referring. So, the indexes have to be the same.
    – yangtzech
    Mar 8, 2023 at 12:34


You must log in to answer this question.

Browse other questions tagged .