Have figures and tables under sections in table of contents

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












So currently, the only way to integrate tables and figure in table of contents is to have them setup after the tableofcontents using listoffigures and listoftables. My professor asked for a report to have those indented in the table of contents.



Basically, I need to achieve this:
What I want to achieve
but I only seem to be able to achieve this:
What I currently get



Here is a copy of my code for this file:



documentclass[11pt, A4]article

usepackagegraphicx
usepackagebooktabs

begindocument

addcontentslinetocsectionTable of contents
tableofcontents
listoftables
listoffigures
newpage

sectionFirst Section
beginfigure[!h]
includegraphics[height=3cm]image
captionThis is an image
labelimg
endfigure

sectionSecond Section
begintable[!h]
captionJust a table
labeltabl
begincenter
begintabularl
toprule
& title & \
toprule
a & b & c \
hline
d & e & f \
hline
g & h & i
endtabular
endcenter
endtable


enddocument


Here is what the rest of the document looks like:
enter image description here










share|improve this question







New contributor




Benjamin Chausse is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    2
    down vote

    favorite












    So currently, the only way to integrate tables and figure in table of contents is to have them setup after the tableofcontents using listoffigures and listoftables. My professor asked for a report to have those indented in the table of contents.



    Basically, I need to achieve this:
    What I want to achieve
    but I only seem to be able to achieve this:
    What I currently get



    Here is a copy of my code for this file:



    documentclass[11pt, A4]article

    usepackagegraphicx
    usepackagebooktabs

    begindocument

    addcontentslinetocsectionTable of contents
    tableofcontents
    listoftables
    listoffigures
    newpage

    sectionFirst Section
    beginfigure[!h]
    includegraphics[height=3cm]image
    captionThis is an image
    labelimg
    endfigure

    sectionSecond Section
    begintable[!h]
    captionJust a table
    labeltabl
    begincenter
    begintabularl
    toprule
    & title & \
    toprule
    a & b & c \
    hline
    d & e & f \
    hline
    g & h & i
    endtabular
    endcenter
    endtable


    enddocument


    Here is what the rest of the document looks like:
    enter image description here










    share|improve this question







    New contributor




    Benjamin Chausse is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      So currently, the only way to integrate tables and figure in table of contents is to have them setup after the tableofcontents using listoffigures and listoftables. My professor asked for a report to have those indented in the table of contents.



      Basically, I need to achieve this:
      What I want to achieve
      but I only seem to be able to achieve this:
      What I currently get



      Here is a copy of my code for this file:



      documentclass[11pt, A4]article

      usepackagegraphicx
      usepackagebooktabs

      begindocument

      addcontentslinetocsectionTable of contents
      tableofcontents
      listoftables
      listoffigures
      newpage

      sectionFirst Section
      beginfigure[!h]
      includegraphics[height=3cm]image
      captionThis is an image
      labelimg
      endfigure

      sectionSecond Section
      begintable[!h]
      captionJust a table
      labeltabl
      begincenter
      begintabularl
      toprule
      & title & \
      toprule
      a & b & c \
      hline
      d & e & f \
      hline
      g & h & i
      endtabular
      endcenter
      endtable


      enddocument


      Here is what the rest of the document looks like:
      enter image description here










      share|improve this question







      New contributor




      Benjamin Chausse is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      So currently, the only way to integrate tables and figure in table of contents is to have them setup after the tableofcontents using listoffigures and listoftables. My professor asked for a report to have those indented in the table of contents.



      Basically, I need to achieve this:
      What I want to achieve
      but I only seem to be able to achieve this:
      What I currently get



      Here is a copy of my code for this file:



      documentclass[11pt, A4]article

      usepackagegraphicx
      usepackagebooktabs

      begindocument

      addcontentslinetocsectionTable of contents
      tableofcontents
      listoftables
      listoffigures
      newpage

      sectionFirst Section
      beginfigure[!h]
      includegraphics[height=3cm]image
      captionThis is an image
      labelimg
      endfigure

      sectionSecond Section
      begintable[!h]
      captionJust a table
      labeltabl
      begincenter
      begintabularl
      toprule
      & title & \
      toprule
      a & b & c \
      hline
      d & e & f \
      hline
      g & h & i
      endtabular
      endcenter
      endtable


      enddocument


      Here is what the rest of the document looks like:
      enter image description here







      table-of-contents floats






      share|improve this question







      New contributor




      Benjamin Chausse is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Benjamin Chausse is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Benjamin Chausse is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 hours ago









      Benjamin Chausse

      112




      112




      New contributor




      Benjamin Chausse is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Benjamin Chausse is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Benjamin Chausse is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote













          Here is a suggestion using tocbasic for the format of the figure and table entries (and for the entry of the TOC in the TOC):



          documentclass[11pt, a4]article

          makeatletter
          renewcommand*ext@figuretoc
          renewcommand*ext@tabletoc
          makeatother

          usepackagetocbasic
          addtotoclist[jobname]toc
          renewcommand*tableofcontentslistoftoc[contentsname]toc
          setuptoctoctotoc% TOC entry in TOC

          newcommandentrywithprefix[2]hfill#1~#2 -
          DeclareTOCStyleEntry[
          numwidth=6em,
          entrynumberformat=entrywithprefixtablename
          ]toclinefigure
          DeclareTOCStyleEntry[
          numwidth=6em,
          entrynumberformat=entrywithprefixfigurename
          ]toclinetable

          usepackagegraphicx
          usepackagebooktabs

          begindocument
          tableofcontents

          clearpage
          sectionFirst Section
          beginfigure[htbp]
          includegraphics[height=3cm]example-image-a
          captionThis is an image
          labelimg1
          endfigure
          beginfigure[htbp]
          includegraphics[height=3cm]example-image-b
          captionThis is another image
          labelimg2
          endfigure
          begintable[htbp]
          captionJust a table in first section
          labeltabl
          begincenter
          begintabularl
          toprule
          & title & \
          toprule
          a & b & c \
          hline
          d & e & f \
          hline
          g & h & i
          endtabular
          endcenter
          endtable

          sectionSecond Section
          begintable[htbp]
          captionJust a table in second section
          labeltabl2
          begincenter
          begintabularl
          toprule
          & title & \
          toprule
          a & b & c \
          hline
          d & e & f \
          hline
          g & h & i
          endtabular
          endcenter
          endtable

          beginfigure[htbp]
          includegraphics[height=3cm]example-image-a
          captionThis is an image in second section
          labelimg3
          endfigure
          enddocument


          Result:



          enter image description here






          share|improve this answer



























            up vote
            1
            down vote













            documentclass[11pt, a4paper]article}

            usepackagegraphicx
            usepackagebooktabs

            makeatletter
            defext@figure toc
            defext@table toc
            makeatother

            begindocument

            addcontentslinetocsectionTable of contents
            tableofcontents
            %listoftables
            %listoffigures
            newpage

            sectionFirst Section
            beginfigure[htbp]
            includegraphics[height=3cm]example-image-a
            captionThis is an image
            labelimg1
            endfigure
            beginfigure[htbp]
            includegraphics[height=3cm]example-image-b
            captionThis is another image
            labelimg2
            endfigure
            begintable[htbp]
            captionJust a table in first section
            labeltabl
            begincenter
            begintabularl
            toprule
            & title & \
            toprule
            a & b & c \
            hline
            d & e & f \
            hline
            g & h & i
            endtabular
            endcenter
            endtable

            sectionSecond Section
            begintable[htbp]
            captionJust a table in second section
            labeltabl2
            begincenter
            begintabularl
            toprule
            & title & \
            toprule
            a & b & c \
            hline
            d & e & f \
            hline
            g & h & i
            endtabular
            endcenter
            endtable

            beginfigure[htbp]
            includegraphics[height=3cm]example-image-a
            captionThis is an image in second section
            labelimg3
            endfigure

            enddocument


            enter image description here



            update



            To obtain this:



            enter image description here



            use this in preamble:



            makeatletter
            defext@figuretoc
            defext@table toc

            letoriginalnumberlinenumberline

            defl@figuredefnumberline##1makebox[2cm][l]Figurehrulefill##1: %
            globalletnumberlineoriginalnumberline%
            l@subsection

            defl@tabledefnumberline##1makebox[2cm][l]Tablehrulefill##1: %
            globalletnumberlineoriginalnumberline%
            l@subsection
            makeatother





            share|improve this answer






















              Your Answer







              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "85"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );






              Benjamin Chausse is a new contributor. Be nice, and check out our Code of Conduct.









               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f456401%2fhave-figures-and-tables-under-sections-in-table-of-contents%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              3
              down vote













              Here is a suggestion using tocbasic for the format of the figure and table entries (and for the entry of the TOC in the TOC):



              documentclass[11pt, a4]article

              makeatletter
              renewcommand*ext@figuretoc
              renewcommand*ext@tabletoc
              makeatother

              usepackagetocbasic
              addtotoclist[jobname]toc
              renewcommand*tableofcontentslistoftoc[contentsname]toc
              setuptoctoctotoc% TOC entry in TOC

              newcommandentrywithprefix[2]hfill#1~#2 -
              DeclareTOCStyleEntry[
              numwidth=6em,
              entrynumberformat=entrywithprefixtablename
              ]toclinefigure
              DeclareTOCStyleEntry[
              numwidth=6em,
              entrynumberformat=entrywithprefixfigurename
              ]toclinetable

              usepackagegraphicx
              usepackagebooktabs

              begindocument
              tableofcontents

              clearpage
              sectionFirst Section
              beginfigure[htbp]
              includegraphics[height=3cm]example-image-a
              captionThis is an image
              labelimg1
              endfigure
              beginfigure[htbp]
              includegraphics[height=3cm]example-image-b
              captionThis is another image
              labelimg2
              endfigure
              begintable[htbp]
              captionJust a table in first section
              labeltabl
              begincenter
              begintabularl
              toprule
              & title & \
              toprule
              a & b & c \
              hline
              d & e & f \
              hline
              g & h & i
              endtabular
              endcenter
              endtable

              sectionSecond Section
              begintable[htbp]
              captionJust a table in second section
              labeltabl2
              begincenter
              begintabularl
              toprule
              & title & \
              toprule
              a & b & c \
              hline
              d & e & f \
              hline
              g & h & i
              endtabular
              endcenter
              endtable

              beginfigure[htbp]
              includegraphics[height=3cm]example-image-a
              captionThis is an image in second section
              labelimg3
              endfigure
              enddocument


              Result:



              enter image description here






              share|improve this answer
























                up vote
                3
                down vote













                Here is a suggestion using tocbasic for the format of the figure and table entries (and for the entry of the TOC in the TOC):



                documentclass[11pt, a4]article

                makeatletter
                renewcommand*ext@figuretoc
                renewcommand*ext@tabletoc
                makeatother

                usepackagetocbasic
                addtotoclist[jobname]toc
                renewcommand*tableofcontentslistoftoc[contentsname]toc
                setuptoctoctotoc% TOC entry in TOC

                newcommandentrywithprefix[2]hfill#1~#2 -
                DeclareTOCStyleEntry[
                numwidth=6em,
                entrynumberformat=entrywithprefixtablename
                ]toclinefigure
                DeclareTOCStyleEntry[
                numwidth=6em,
                entrynumberformat=entrywithprefixfigurename
                ]toclinetable

                usepackagegraphicx
                usepackagebooktabs

                begindocument
                tableofcontents

                clearpage
                sectionFirst Section
                beginfigure[htbp]
                includegraphics[height=3cm]example-image-a
                captionThis is an image
                labelimg1
                endfigure
                beginfigure[htbp]
                includegraphics[height=3cm]example-image-b
                captionThis is another image
                labelimg2
                endfigure
                begintable[htbp]
                captionJust a table in first section
                labeltabl
                begincenter
                begintabularl
                toprule
                & title & \
                toprule
                a & b & c \
                hline
                d & e & f \
                hline
                g & h & i
                endtabular
                endcenter
                endtable

                sectionSecond Section
                begintable[htbp]
                captionJust a table in second section
                labeltabl2
                begincenter
                begintabularl
                toprule
                & title & \
                toprule
                a & b & c \
                hline
                d & e & f \
                hline
                g & h & i
                endtabular
                endcenter
                endtable

                beginfigure[htbp]
                includegraphics[height=3cm]example-image-a
                captionThis is an image in second section
                labelimg3
                endfigure
                enddocument


                Result:



                enter image description here






                share|improve this answer






















                  up vote
                  3
                  down vote










                  up vote
                  3
                  down vote









                  Here is a suggestion using tocbasic for the format of the figure and table entries (and for the entry of the TOC in the TOC):



                  documentclass[11pt, a4]article

                  makeatletter
                  renewcommand*ext@figuretoc
                  renewcommand*ext@tabletoc
                  makeatother

                  usepackagetocbasic
                  addtotoclist[jobname]toc
                  renewcommand*tableofcontentslistoftoc[contentsname]toc
                  setuptoctoctotoc% TOC entry in TOC

                  newcommandentrywithprefix[2]hfill#1~#2 -
                  DeclareTOCStyleEntry[
                  numwidth=6em,
                  entrynumberformat=entrywithprefixtablename
                  ]toclinefigure
                  DeclareTOCStyleEntry[
                  numwidth=6em,
                  entrynumberformat=entrywithprefixfigurename
                  ]toclinetable

                  usepackagegraphicx
                  usepackagebooktabs

                  begindocument
                  tableofcontents

                  clearpage
                  sectionFirst Section
                  beginfigure[htbp]
                  includegraphics[height=3cm]example-image-a
                  captionThis is an image
                  labelimg1
                  endfigure
                  beginfigure[htbp]
                  includegraphics[height=3cm]example-image-b
                  captionThis is another image
                  labelimg2
                  endfigure
                  begintable[htbp]
                  captionJust a table in first section
                  labeltabl
                  begincenter
                  begintabularl
                  toprule
                  & title & \
                  toprule
                  a & b & c \
                  hline
                  d & e & f \
                  hline
                  g & h & i
                  endtabular
                  endcenter
                  endtable

                  sectionSecond Section
                  begintable[htbp]
                  captionJust a table in second section
                  labeltabl2
                  begincenter
                  begintabularl
                  toprule
                  & title & \
                  toprule
                  a & b & c \
                  hline
                  d & e & f \
                  hline
                  g & h & i
                  endtabular
                  endcenter
                  endtable

                  beginfigure[htbp]
                  includegraphics[height=3cm]example-image-a
                  captionThis is an image in second section
                  labelimg3
                  endfigure
                  enddocument


                  Result:



                  enter image description here






                  share|improve this answer












                  Here is a suggestion using tocbasic for the format of the figure and table entries (and for the entry of the TOC in the TOC):



                  documentclass[11pt, a4]article

                  makeatletter
                  renewcommand*ext@figuretoc
                  renewcommand*ext@tabletoc
                  makeatother

                  usepackagetocbasic
                  addtotoclist[jobname]toc
                  renewcommand*tableofcontentslistoftoc[contentsname]toc
                  setuptoctoctotoc% TOC entry in TOC

                  newcommandentrywithprefix[2]hfill#1~#2 -
                  DeclareTOCStyleEntry[
                  numwidth=6em,
                  entrynumberformat=entrywithprefixtablename
                  ]toclinefigure
                  DeclareTOCStyleEntry[
                  numwidth=6em,
                  entrynumberformat=entrywithprefixfigurename
                  ]toclinetable

                  usepackagegraphicx
                  usepackagebooktabs

                  begindocument
                  tableofcontents

                  clearpage
                  sectionFirst Section
                  beginfigure[htbp]
                  includegraphics[height=3cm]example-image-a
                  captionThis is an image
                  labelimg1
                  endfigure
                  beginfigure[htbp]
                  includegraphics[height=3cm]example-image-b
                  captionThis is another image
                  labelimg2
                  endfigure
                  begintable[htbp]
                  captionJust a table in first section
                  labeltabl
                  begincenter
                  begintabularl
                  toprule
                  & title & \
                  toprule
                  a & b & c \
                  hline
                  d & e & f \
                  hline
                  g & h & i
                  endtabular
                  endcenter
                  endtable

                  sectionSecond Section
                  begintable[htbp]
                  captionJust a table in second section
                  labeltabl2
                  begincenter
                  begintabularl
                  toprule
                  & title & \
                  toprule
                  a & b & c \
                  hline
                  d & e & f \
                  hline
                  g & h & i
                  endtabular
                  endcenter
                  endtable

                  beginfigure[htbp]
                  includegraphics[height=3cm]example-image-a
                  captionThis is an image in second section
                  labelimg3
                  endfigure
                  enddocument


                  Result:



                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 1 hour ago









                  esdd

                  56.6k34383




                  56.6k34383




















                      up vote
                      1
                      down vote













                      documentclass[11pt, a4paper]article}

                      usepackagegraphicx
                      usepackagebooktabs

                      makeatletter
                      defext@figure toc
                      defext@table toc
                      makeatother

                      begindocument

                      addcontentslinetocsectionTable of contents
                      tableofcontents
                      %listoftables
                      %listoffigures
                      newpage

                      sectionFirst Section
                      beginfigure[htbp]
                      includegraphics[height=3cm]example-image-a
                      captionThis is an image
                      labelimg1
                      endfigure
                      beginfigure[htbp]
                      includegraphics[height=3cm]example-image-b
                      captionThis is another image
                      labelimg2
                      endfigure
                      begintable[htbp]
                      captionJust a table in first section
                      labeltabl
                      begincenter
                      begintabularl
                      toprule
                      & title & \
                      toprule
                      a & b & c \
                      hline
                      d & e & f \
                      hline
                      g & h & i
                      endtabular
                      endcenter
                      endtable

                      sectionSecond Section
                      begintable[htbp]
                      captionJust a table in second section
                      labeltabl2
                      begincenter
                      begintabularl
                      toprule
                      & title & \
                      toprule
                      a & b & c \
                      hline
                      d & e & f \
                      hline
                      g & h & i
                      endtabular
                      endcenter
                      endtable

                      beginfigure[htbp]
                      includegraphics[height=3cm]example-image-a
                      captionThis is an image in second section
                      labelimg3
                      endfigure

                      enddocument


                      enter image description here



                      update



                      To obtain this:



                      enter image description here



                      use this in preamble:



                      makeatletter
                      defext@figuretoc
                      defext@table toc

                      letoriginalnumberlinenumberline

                      defl@figuredefnumberline##1makebox[2cm][l]Figurehrulefill##1: %
                      globalletnumberlineoriginalnumberline%
                      l@subsection

                      defl@tabledefnumberline##1makebox[2cm][l]Tablehrulefill##1: %
                      globalletnumberlineoriginalnumberline%
                      l@subsection
                      makeatother





                      share|improve this answer


























                        up vote
                        1
                        down vote













                        documentclass[11pt, a4paper]article}

                        usepackagegraphicx
                        usepackagebooktabs

                        makeatletter
                        defext@figure toc
                        defext@table toc
                        makeatother

                        begindocument

                        addcontentslinetocsectionTable of contents
                        tableofcontents
                        %listoftables
                        %listoffigures
                        newpage

                        sectionFirst Section
                        beginfigure[htbp]
                        includegraphics[height=3cm]example-image-a
                        captionThis is an image
                        labelimg1
                        endfigure
                        beginfigure[htbp]
                        includegraphics[height=3cm]example-image-b
                        captionThis is another image
                        labelimg2
                        endfigure
                        begintable[htbp]
                        captionJust a table in first section
                        labeltabl
                        begincenter
                        begintabularl
                        toprule
                        & title & \
                        toprule
                        a & b & c \
                        hline
                        d & e & f \
                        hline
                        g & h & i
                        endtabular
                        endcenter
                        endtable

                        sectionSecond Section
                        begintable[htbp]
                        captionJust a table in second section
                        labeltabl2
                        begincenter
                        begintabularl
                        toprule
                        & title & \
                        toprule
                        a & b & c \
                        hline
                        d & e & f \
                        hline
                        g & h & i
                        endtabular
                        endcenter
                        endtable

                        beginfigure[htbp]
                        includegraphics[height=3cm]example-image-a
                        captionThis is an image in second section
                        labelimg3
                        endfigure

                        enddocument


                        enter image description here



                        update



                        To obtain this:



                        enter image description here



                        use this in preamble:



                        makeatletter
                        defext@figuretoc
                        defext@table toc

                        letoriginalnumberlinenumberline

                        defl@figuredefnumberline##1makebox[2cm][l]Figurehrulefill##1: %
                        globalletnumberlineoriginalnumberline%
                        l@subsection

                        defl@tabledefnumberline##1makebox[2cm][l]Tablehrulefill##1: %
                        globalletnumberlineoriginalnumberline%
                        l@subsection
                        makeatother





                        share|improve this answer
























                          up vote
                          1
                          down vote










                          up vote
                          1
                          down vote









                          documentclass[11pt, a4paper]article}

                          usepackagegraphicx
                          usepackagebooktabs

                          makeatletter
                          defext@figure toc
                          defext@table toc
                          makeatother

                          begindocument

                          addcontentslinetocsectionTable of contents
                          tableofcontents
                          %listoftables
                          %listoffigures
                          newpage

                          sectionFirst Section
                          beginfigure[htbp]
                          includegraphics[height=3cm]example-image-a
                          captionThis is an image
                          labelimg1
                          endfigure
                          beginfigure[htbp]
                          includegraphics[height=3cm]example-image-b
                          captionThis is another image
                          labelimg2
                          endfigure
                          begintable[htbp]
                          captionJust a table in first section
                          labeltabl
                          begincenter
                          begintabularl
                          toprule
                          & title & \
                          toprule
                          a & b & c \
                          hline
                          d & e & f \
                          hline
                          g & h & i
                          endtabular
                          endcenter
                          endtable

                          sectionSecond Section
                          begintable[htbp]
                          captionJust a table in second section
                          labeltabl2
                          begincenter
                          begintabularl
                          toprule
                          & title & \
                          toprule
                          a & b & c \
                          hline
                          d & e & f \
                          hline
                          g & h & i
                          endtabular
                          endcenter
                          endtable

                          beginfigure[htbp]
                          includegraphics[height=3cm]example-image-a
                          captionThis is an image in second section
                          labelimg3
                          endfigure

                          enddocument


                          enter image description here



                          update



                          To obtain this:



                          enter image description here



                          use this in preamble:



                          makeatletter
                          defext@figuretoc
                          defext@table toc

                          letoriginalnumberlinenumberline

                          defl@figuredefnumberline##1makebox[2cm][l]Figurehrulefill##1: %
                          globalletnumberlineoriginalnumberline%
                          l@subsection

                          defl@tabledefnumberline##1makebox[2cm][l]Tablehrulefill##1: %
                          globalletnumberlineoriginalnumberline%
                          l@subsection
                          makeatother





                          share|improve this answer














                          documentclass[11pt, a4paper]article}

                          usepackagegraphicx
                          usepackagebooktabs

                          makeatletter
                          defext@figure toc
                          defext@table toc
                          makeatother

                          begindocument

                          addcontentslinetocsectionTable of contents
                          tableofcontents
                          %listoftables
                          %listoffigures
                          newpage

                          sectionFirst Section
                          beginfigure[htbp]
                          includegraphics[height=3cm]example-image-a
                          captionThis is an image
                          labelimg1
                          endfigure
                          beginfigure[htbp]
                          includegraphics[height=3cm]example-image-b
                          captionThis is another image
                          labelimg2
                          endfigure
                          begintable[htbp]
                          captionJust a table in first section
                          labeltabl
                          begincenter
                          begintabularl
                          toprule
                          & title & \
                          toprule
                          a & b & c \
                          hline
                          d & e & f \
                          hline
                          g & h & i
                          endtabular
                          endcenter
                          endtable

                          sectionSecond Section
                          begintable[htbp]
                          captionJust a table in second section
                          labeltabl2
                          begincenter
                          begintabularl
                          toprule
                          & title & \
                          toprule
                          a & b & c \
                          hline
                          d & e & f \
                          hline
                          g & h & i
                          endtabular
                          endcenter
                          endtable

                          beginfigure[htbp]
                          includegraphics[height=3cm]example-image-a
                          captionThis is an image in second section
                          labelimg3
                          endfigure

                          enddocument


                          enter image description here



                          update



                          To obtain this:



                          enter image description here



                          use this in preamble:



                          makeatletter
                          defext@figuretoc
                          defext@table toc

                          letoriginalnumberlinenumberline

                          defl@figuredefnumberline##1makebox[2cm][l]Figurehrulefill##1: %
                          globalletnumberlineoriginalnumberline%
                          l@subsection

                          defl@tabledefnumberline##1makebox[2cm][l]Tablehrulefill##1: %
                          globalletnumberlineoriginalnumberline%
                          l@subsection
                          makeatother






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 37 mins ago

























                          answered 1 hour ago









                          jfbu

                          43.4k65141




                          43.4k65141




















                              Benjamin Chausse is a new contributor. Be nice, and check out our Code of Conduct.









                               

                              draft saved


                              draft discarded


















                              Benjamin Chausse is a new contributor. Be nice, and check out our Code of Conduct.












                              Benjamin Chausse is a new contributor. Be nice, and check out our Code of Conduct.











                              Benjamin Chausse is a new contributor. Be nice, and check out our Code of Conduct.













                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f456401%2fhave-figures-and-tables-under-sections-in-table-of-contents%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Comments

                              Popular posts from this blog

                              Long meetings (6-7 hours a day): Being “babysat” by supervisor

                              Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                              Confectionery