그림 및 표 목록

그림 및 표 목록

나는 알고있어그림과 표를 합친 목록인가요?, 하지만 질문자는 다음을 요구합니다.하나내가 원하지 않는 그림과 표의 번호 매기기 체계. 불행하게도 대답은 그 전제조건에 달려 있는 것 같습니다.

내 질문은 다음과 같은 의도된 결과/출력에 관한 것입니다.


그림 및 표 목록

그림 1: 뉴올리언스의 나무 지도 .............................................. 3

그림 2: 하루에 떨어지는 나뭇잎의 수 ........................ 5

표 1: 나무의 종류 .............................................. ............ 12

그림 3: 낙엽 1,000개당 공기질 감소 .............. 20


이것이 작동하려면 위의 링크에서 제안한 것처럼 그림을 테이블(또는 그 반대)로 재정의하는 것(예: \let\figure\table\let\endtable\endfigure)은 물론 모든 그림이 "테이블 x"로 호출되기 때문에 작동하지 않습니다. .

답변1

이것은 작동합니다. 코드에 주석이 잘 달려 있어서 더 이상 주석이 필요하지 않을 것 같습니다.

여기에 이미지 설명을 입력하세요

\documentclass{article}

% To make the page shorter
\pagestyle{empty}
\textheight3in

% CODE STARTS HERE
% Based on `tocloft` package
\usepackage[titles]{tocloft}
\newlistof{figtab}{loft}{List of Figures and Tables}
\makeatletter
% Change the file extension of both lot and lof
\def\ext@figure{loft}
\def\ext@table{loft}
% Store the original `\thefigure` and `\thetable`
\let\tohe@thefigure\thefigure
\let\tohe@thetable\thetable
% Redefine them to contain a "dummy" `\tohe@list...`
\def\thefigure{\tohe@listfig\tohe@thefigure}
\def\thetable{\tohe@listtab\tohe@thetable}
% Make the two dummy commands truly dummy
\let\tohe@listfig\relax
\let\tohe@listtab\relax
% Store the original `\listoffigtab`
\let\tohe@listoffigtab\listoffigtab
% Redefine it in such a way that the dummy commands insert "Fig." or "Tab." respectively
\def\listoffigtab{%
  \begingroup
  \def\tohe@listfig{Fig.~}
  \def\tohe@listtab{Tab.~}
  \tohe@listoffigtab
  \endgroup  
}
% Change \listoffigtab spacing
\setlength{\cftfignumwidth}{5em}
\setlength{\cfttabnumwidth}{5em}
\setlength{\cftfigindent}{0pt}
\setlength{\cfttabindent}{0pt}
\makeatother
% CODE ENDS HERE

\begin{document}

\listoffigtab

% !b just to make the floats appear on the bottom of the first page
\begin{figure}[!b]
\caption{First}
\end{figure}

\begin{table}[!b]
\caption{Little Table}
\end{table}

\begin{figure}[!b]
\caption{Second}
\end{figure}

\end{document}

답변2

관련 명령은 'always' 입니다 \addcontentsline.

figure캡션 은 확장자가 또는 table에 저장된 파일에 기록됩니다 .\ext@figure\ext@table

\@caption(실제로 내부 프로세서 매크로) 에서 우리는 다음을 발견합니다:

\long\def\@caption#1[#2]#3{%
  \par
  \addcontentsline{\csname ext@#1\endcsname}{#1}%
    {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  \begingroup
    \@parboxrestore
    \if@minipage
      \@setminipage
    \fi
    \normalsize
    \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
  \endgroup}

의 첫 번째 매개변수 \@caption는 float의 이름입니다(예: figure또는 table(보통)). 이를 사용하고 패치하여 table캡션과 redirect확장자가 \ext@figure.

\documentclass{book}

\usepackage{caption}
\usepackage{xstring}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\@caption}{%
  \addcontentsline{\csname ext@#1\endcsname}{#1}%
  {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
}{%
  \IfStrEq{#1}{table}{% Filter `table` out
    \addcontentsline{\csname ext@figure\endcsname}{table}%
    {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  }{%
    \addcontentsline{\csname ext@#1\endcsname}{#1}%
    {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  }%
}{\typeout{Patch success}}{}
\makeatother

\renewcommand{\listfigurename}{List of Figures and Tables}

\begin{document}
\listoffigures
\begin{figure}
\caption{first figure}
\end{figure}

\begin{figure}
\caption{Another first figure}
\end{figure}


\begin{table}
\caption{first table}
\end{table}

\chapter{Another chapter}
\begin{table}
\caption{Yet another table}
\end{table}

\end{document}

여기에 이미지 설명을 입력하세요

yo'LOFT의 테이블인지 그림인지 확실하지 않다는 사실을 올바르게 확인한 후 작은 업데이트 :

\documentclass{book}

\usepackage{caption}
\usepackage{xstring}
\usepackage{tocloft}
\usepackage{xpatch}

\addtolength{\cftfignumwidth}{30pt}
\addtolength{\cfttabnumwidth}{30pt}
% Prepend the tab or fig number with a `\makebox` (for equal width) and put `Tab.` or `Fig.` in there. Change the names at will 
\renewcommand{\cfttabpresnum}{\makebox[30pt][l]{Tab.}}  
\renewcommand{\cftfigpresnum}{\makebox[30pt][l]{Fig.}}  


\makeatletter
\xpatchcmd{\@caption}{%
  \addcontentsline{\csname ext@#1\endcsname}{#1}%
  {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
}{%
  \IfStrEq{#1}{table}{%
    \addcontentsline{\csname ext@figure\endcsname}{table}%
    {\protect\numberline{\csname the#1\endcsname\hfill\hspace{1em}}{\ignorespaces #2}}%
  }{%
    \IfStrEq{#1}{figure}{%
      \addcontentsline{\csname ext@#1\endcsname}{#1}%
      {\protect\numberline{\csname the#1\endcsname\hfill\hspace{1em}}{\ignorespaces #2}}%
    }{%
     \addcontentsline{\csname ext@#1\endcsname}{#1}%
     {\protect\numberline{\csname the#1\endcsname}{ \ignorespaces #2}}%
    }
  }%
}{\typeout{Patch success}}{}
\makeatother

\renewcommand{\listfigurename}{List of Figures and Tables}

\begin{document}
\listoffigures
\begin{figure}
\caption{first figure}
\end{figure}

\begin{figure}
\caption{Another first figure}
\end{figure}


\begin{table}
\caption{first table}
\end{table}

\chapter{Another chapter}
\begin{table}
\caption{Yet another table}
\end{table}

\section{First section}
\subsection{First subsection}
\subsubsection{First subsubsection}
\begin{table}
\caption{Yet another another table}
\end{table}


\end{document}

여기에 이미지 설명을 입력하세요

관련 정보