圖表清單中的單倍行距長標題超過一行

圖表清單中的單倍行距長標題超過一行

我嘗試了該解決方案\caption[\protect\vspace{-0.5ex}{ long caption text}]{long caption text},但它沒有任何作用。我需要在 LOF 中使用恆定的雙倍間距,當涉及超過一行的長標題時,它必須是單倍間距。能否請你幫忙?謝謝。

\documentclass[12pt,oneside,letterpaper,chapterprefix=on,numbers=noenddot]{scrbook}
\setuptoc{toc}{leveldown}% if ToC should be on section level
\usepackage[english]{babel}
%%% document setup
\usepackage[demo]{graphicx}


\usepackage[list-entry=heading]{caption}
\usepackage{booktabs}% table
\usepackage[doublespacing]{setspace}% <- changed


\setkomafont{captionlabel}{\bfseries}%make caption label bold
\setkomafont{caption}{\bfseries}%make caption bold
\setcapindent{0pt}%removes hanging indent from captions





%----------------%-------------------------%-----------
\begin{document}

\begingroup
\def\addvspace#1{}
\clearpage % to force a new page
\addcontentsline{toc}{chapter}{LIST OF FIGURES}
\listoffigures
%\doublespacing
\endgroup
\mainmatter

\begin{figure}
\includegraphics{test}
\caption[\protect\vspace{-0.25ex}{ llong caption text 2long caption text 3long caption text 4long caption text 5long caption text }]{1long caption text 2long caption text 3long caption text 4long caption text 5long caption text 6long caption text}
\end{figure}
\begin{figure}


\includegraphics{test2}
\caption[\protect\vspace{-0.5ex}{ llong caption text 2long caption text 3long caption text 4long caption text 5long caption text }]{1long caption text 2long caption text 3long caption text 4long caption text 5long caption text 6long caption text}
\end{figure}
\end{document}

答案1

因此,將圖形(和其他目錄)列表設為單倍行距,您可以在最開始處添加一個\singlespacing\setstretch{1},可以緊接在標題之後使用\AfterTOCHead,或者緊接在讀取相應目錄的輔助文件之前使用\BeforeStartingTOC,例如

\BeforeStartingTOC[lof]{\singlespacing}% for the list of figures only

或者

\BeforeStartingTOC{\singlespacing}% for every TOC (i.e. table of contents, list of figures, list of tables)

若要在圖形清單的條目之間新增白線,您可以變更選項beforeskip,例如使用

\DeclareTOCStyleEntry[beforeskip=\baselineskip]{tocline}{figure}

必須對所有應該擁有它的條目類型執行此操作。對於表,複製命令並替換figuretable

有關詳細信息,請參閱tocbasicKOMA-Script 手冊中的章節。

對於目錄條目,您也可以使用

\RedeclareSectionCommands[tocbeforeskip=\baselineskip]{section,subsection}

有關 的更多信息,請參閱 KOMA-Script 手冊的第二部分\RedeclareSectionCommand

若要將圖形清單和表格清單放入目錄中,您還應該使用特殊的 KOMA-Script 功能: option listof=totoc。要從這些清單中刪除章節間隙,您也不需要在本地重新定義,\addvspace但可以使用 option listof=nochaptergap

透過這些更改,您不再需要使用 的可選參數\caption

\documentclass[12pt,oneside,letterpaper,chapterprefix=on,numbers=noenddot,
  listof=totoc,listof=nochaptergap% <--- ADDED
]{scrbook}
\setuptoc{toc}{leveldown}% if ToC should be on section level
\usepackage[english]{babel}
%%% document setup
\usepackage[demo]{graphicx}


\usepackage[list-entry=heading]{caption}
\usepackage{booktabs}% table
\usepackage[doublespacing]{setspace}

\setkomafont{captionlabel}{\bfseries}%make caption label bold
\setkomafont{caption}{\bfseries}%make caption bold
\setcapindent{0pt}%removes hanging indent from captions

\BeforeStartingTOC{\singlespacing}% <--- ADDED
\DeclareTOCStyleEntry[beforeskip=\baselineskip]{tocline}{figure}
\DeclareTOCStyleEntry[beforeskip=\baselineskip]{tocline}{table}    

%----------------%-------------------------%-----------
\begin{document}

\frontmatter% <--- ADDED (without \mainmatter wouldn't make sense)

% CHANGED:
\listoffigures
\mainmatter

\begin{figure}
\includegraphics{test}
\caption{llong caption text 2long caption text 3long caption text 4long caption text 5long caption text}
\end{figure}
\begin{figure}


\includegraphics{test2}
\caption{llong caption text 2long caption text 3long caption text 4long caption text 5long caption text}
\end{figure}
\end{document}

在此輸入影像描述

答案2

圖形列表用於\l@figure進行格式化,因此我添加了一個額外的\vspace{\baselineskip}.這應該適用於任何文檔類。

雙倍行距是由打字機完成的。排字機在行之間增加額外的空間。

\documentclass[12pt,oneside,letterpaper,chapterprefix=on,numbers=noenddot]{scrbook}
\setuptoc{toc}{leveldown}% if ToC should be on section level
\usepackage[english]{babel}
%%% document setup
\usepackage[demo]{graphicx}


\usepackage[list-entry=heading]{caption}
\usepackage{booktabs}% table
%\usepackage[doublespacing]{setspace}% <- changed


\setkomafont{captionlabel}{\bfseries}%make caption label bold
\setkomafont{caption}{\bfseries}%make caption bold
\setcapindent{0pt}%removes hanging indent from captions

\makeatletter
\let\oldl@figure=\l@figure
\renewcommand{\l@figure}{\vspace{\baselineskip}\oldl@figure}
\makeatother

\begin{document}

\begingroup
\def\addvspace#1{}
\clearpage % to force a new page
\addcontentsline{toc}{chapter}{LIST OF FIGURES}
\listoffigures}%\doublespacing
\endgroup
\mainmatter

\begin{figure}
\includegraphics{test}
\caption{1long caption text 2long caption text 3long caption text 4long caption text 5long caption text 6long caption text}
\end{figure}
\begin{figure}


\includegraphics{test2}
\caption[\protect\vspace{-0.5ex}{ llong caption text 2long caption text 3long caption text 4long caption text 5long caption text }]{1long caption text 2long caption text 3long caption text 4long caption text 5long caption text 6long caption text}
\end{figure}
\end{document}

相關內容