目录中的章节描述,但宽度固定

目录中的章节描述,但宽度固定

我真的很喜欢使用接受的答案获得的目录 在目录中添加每章图片和条目组

但是,我不想在目录中列出章节,而是想包含章节内容的简短描述。但是,无论我怎么努力,我都无法让这些描述不覆盖图像。我尝试了以下方法,但都不起作用:

有没有办法让这些文本表现良好,并远离图像?下面是我正在谈论的一个例子:

\documentclass{scrbook}

\usepackage{geometry}% http://ctan.org/pkg/geometry
\usepackage{titletoc}% http://ctan.org/pkg/titletoc
\usepackage[export]{adjustbox}% http://ctan.org/pkg/adjustbox
\usepackage{xparse}% http://ctan.org/pkg/xparse
\usepackage{titlesec}
\usepackage{tocloft}


\NewDocumentCommand{\rtocstuff}{O{10pt} m O{80pt}}{% \rtocstuff[<gap>]{<content>}[<width>
    \titlecontents{chapter}
      [0pt]% left margin indent
      {\bigskip\bfseries}% chapter ToC formatting
      {\makebox[1.5em][l]{\thecontentslabel}}% chapter label (numbered)
      {\hspace*{1.5em}}% chapter label (unnumbered)
      {\titlerule*[1pc]{.}% dotted contents line
       \thecontentspage% ToC page number
       \hspace*{#1}% gap between page number & <content>
       \smash{% remove vertical height of image
         \raisebox{1.5ex}{% align with top of character
           \hspace*{#3}% space for <content>
           \llap{% left overlap
             #2\hspace*{#1}% actual <content>
      }}}}%
      \titlecontents{section}
      [0pt]% left margin indent
      {\normalfont}% section ToC formatting
      {\hspace*{1.5em}\makebox[2.3em][l]{\thecontentslabel}}% section label (numbered)
      {\hspace*{3.8em}}% section label (unnumbered)
      {\titlerule*[1pc]{.}% dotted contents line
       \thecontentspage% ToC page number
       \hspace*{#1}% gap between page number & <content>
       \hspace*{#3}% gap for <content>
      }
}
\NewDocumentCommand{\ltocstuff}{O{80pt} m O{10pt}}{% \ltocstuff[<width>]{<content>}[<gap>]
    \titlecontents{chapter}
      [0pt]% left margin indent
      {\bigskip\bfseries}% chapter ToC formatting
      {\smash{% remove vertical height of image
         \raisebox{1.5ex}{% align with top of character
           \rlap{% right overlap
             #2% actual content
           }\hspace*{#1}% space for <content>
       }}%
       \hspace*{#3}% gap between <content> and ToC entries
       \makebox[1.5em][l]{\thecontentslabel}}% chapter label (numbered)
      {\smash{% remove vertical height of image
         \raisebox{1.5ex}{% align with top of character
           \rlap{% right overlap
             #2% actual <content>
           }\hspace*{#1}% space for <content>
       }}%
       \hspace*{1.5em}}% chapter label (unnumbered)
      {\titlerule*[1pc]{.}% dotted contents line
       \thecontentspage% ToC page number
      }
     \titlecontents{section}
      [0pt]% left margin indent
      {\normalfont}% section ToC formatting
      {\hspace*{#1}% space for <content>
       \hspace*{#3}% gap between <content> and ToC entries
       \hspace*{1.5em}\makebox[2.3em][l]{\thecontentslabel}}% section label (numbered)
      {\hspace*{3.8em}}% section label (unnumbered)
      {\titlerule*[1pc]{.}% dotted contents line
       \thecontentspage% ToC page number
      }
}

\usepackage{lipsum}% http://ctan.org/pkg/lipsum

\newcommand{\ccpt}[1]{\cftchapterprecistoc{#1}}

\begin{document}

\setcounter{tocdepth}{0}
\contentsmargin{0pt}% Remove right margin in ToC
\tableofcontents

\rtocstuff{\includegraphics[valign=T,width=70pt]{tiger}}
\chapter{Coordinates of points}
\ccpt{We will explore how to find the coordinates of various points in the 2-dimensional and 3-dimensional Euclidean spaces.}

\section{Rectangular coordinates} \lipsum[1]
\section{Projections of a segment on the axes} \lipsum[2]
\section{Distance between two points} \lipsum[3]
\section{The mid-point of a segment} \lipsum[4]
\section{Division of a segment in any ratio} \lipsum[5]
\section{Oblique coordinates} \lipsum[6]

\ltocstuff{\includegraphics[valign=T,width=70pt]{tiger}}
\chapter{The locus of an equation}
\ccpt{We will explore how to find the coordinates of various points in the 2-dimensional and 3-dimensional Euclidean spaces.}

\section{First illustrations} \lipsum[1]
\section{Curve plotting} \lipsum[2]
\section{Test that a point lie on a curve} \lipsum[3]
\section{Intercepts} \lipsum[4]
\section{Points of intersection of two curves} \lipsum[5]
\section{Oblique coordinates} \lipsum[6]

\rtocstuff{\includegraphics[valign=T,width=70pt]{tiger}}
\chapter{The straight line}

\section{Equation in terms of point and slope} \lipsum[1]
\section{Line through two points} \lipsum[2]
\section{The general equation of first degree} \lipsum[3]
\section{Parallel and perpendicular lines} \lipsum[4]
\section{Angle between two lines} \lipsum[5]
\section{Distance from a point to a line} \lipsum[6]

\end{document}

答案1

这是一个部分解决方案。我基本上将整个条目排版在一个适当宽度的框中,然后将图像和此框堆叠在一起。这种方法的缺点是它没有利用这些titletoc功能:即您必须手动处理页码和章节号的定位。

更符合titletoc格式的解决方案也行得通,但如果特定部分中的条目没有占用足够的空间,则图像将与下一节重叠。我对界面所做的一项更改是要求\ccpt在章节之前显示,以便在排版章节时可以使用信息(否则很难将其放入框内以保持垂直间距)。

最后,我不确定这里最好的排版选择是什么:章节号应该挂在左对齐部分吗?(如果图像有清晰的边框,则可能挂在左对齐部分;如果图像的线条较弱,则可能不挂在左对齐部分。)同样,页码应该突出到右侧吗?页码和章节号都可能导致空白被卡住,看起来很糟糕。

无论如何,这些都是我将尝试回顾的微调细节,但我想给你一个关于它如何工作的草图。

\documentclass{scrbook}

\usepackage{geometry}% http://ctan.org/pkg/geometry
\usepackage{titletoc}% http://ctan.org/pkg/titletoc
\usepackage[export]{adjustbox}% http://ctan.org/pkg/adjustbox
\usepackage{xparse}% http://ctan.org/pkg/xparse
\usepackage{etoolbox}
\usepackage{titlesec}
%\usepackage{calc}
%\usepackage{tocloft}

\newkomafont{precisentry}{\mdseries\itshape}
\setkomafont{chapterentry}{\bfseries}

\newsavebox{\mytocbox}
\newsavebox{\myfigbox}
\newlength{\mytext}
\newcommand{\myleftskip}{1.5em}  % Space for chapter numbers
\newcommand{\myrightskip}{1.5em} % Space for page numbers

\newif\ifmyrightfig
\newcommand{\titlebox}[4][1em]{%
  %\titlebox[<sep>]{<figure>}{<content>}
  \savebox{\myfigbox}{%
    \raisebox{0.9ex} % Adjust to match fig to letter height.
             {#2}}%
  \settowidth{\mytext}{\usebox{\myfigbox}}%
  \addtolength{\mytext}{-2\mytext}% -\widthof{\myfigbox}
  \addtolength{\mytext}{\textwidth}%
  \addtolength{\mytext}{-#1}%
  \addtolength{\mytext}{-\myleftskip}%
  \addtolength{\mytext}{-\myrightskip}%
  \savebox{\mytocbox}{\parbox[t]{\mytext}{%
      {\usekomafont{chapterentry}%
        \contentslabel{\myleftskip}%
        #3%
        \titlerule*[1pc]{.}\thecontentspage}\\*
      {\usekomafont{precisentry}\csuse{precis}}}}%
  \hbox{%
    \ifmyrightfig
      \hspace{\myleftskip}%
      \usebox{\mytocbox}%
      \hspace{#1}%
      \usebox{\myfigbox}%
    \else
      \usebox{\myfigbox}%
      \hspace{#1}%
      \hspace{\myleftskip}%
      \usebox{\mytocbox}
      \fi}}

\newcommand{\tocstuff}[2][30pt]{
  \titlecontents{chapter}
  [0.0pt]% left margin indent
  {\bigskip}% chapter ToC formatting
  {\titlebox[#1]{#2}}
  {}% chapter label (unnumbered)
  {}% ToC page number
}
\newcommand{\ltocstuff}[2][30pt]{
  \addtocontents{toc}{\protect\myrightfigfalse}
  \tocstuff[#1]{#2}
}
\newcommand{\rtocstuff}[2][30pt]{
  \addtocontents{toc}{\protect\myrightfigtrue}
  \tocstuff[#1]{#2}
}

\usepackage{lipsum}% http://ctan.org/pkg/lipsum

%\newcommand{\ccpt}[1]{\cftchapterprecistoc{#1}}
\newcommand{\defprecis}[1]{\gdef\precis{#1}}
\newcommand{\ccpt}[1]{\addtocontents{toc}{\protect\defprecis{#1}}}


\begin{document}

\setcounter{tocdepth}{0}
\contentsmargin{0pt}% Remove right margin in ToC
\tableofcontents

\rtocstuff{\colorbox{cyan}{\includegraphics[valign=T,width=70pt]{tiger}}}
\ccpt{We will explore how to find the coordinates of various points in the 2-dimensional and 3-dimensional Euclidean spaces.}
\chapter{Coordinates of points with a long title that does not wrap properly and
causes problems}

\section{Rectangular coordinates} \lipsum[1]
\section{Projections of a segment on the axes} \lipsum[2]
\section{Distance between two points} \lipsum[3]
\section{The mid-point of a segment} \lipsum[4]
\section{Division of a segment in any ratio} \lipsum[5]
\section{Oblique coordinates} \lipsum[6]

\ltocstuff{\colorbox{cyan}{\includegraphics[valign=T,width=70pt]{tiger}}}
\ccpt{We will explore how to find the coordinates of various points in the 2-dimensional and 3-dimensional Euclidean spaces.}
\chapter{The locus of an equation}

\section{First illustrations} \lipsum[1]
\section{Curve plotting} \lipsum[2]
\section{Test that a point lie on a curve} \lipsum[3]
\section{Intercepts} \lipsum[4]
\section{Points of intersection of two curves} \lipsum[5]
\section{Oblique coordinates} \lipsum[6]

\rtocstuff{\colorbox{cyan}{\includegraphics[valign=T,width=70pt]{tiger}}}
\chapter{The straight line}

\section{Equation in terms of point and slope} \lipsum[1]
\section{Line through two points} \lipsum[2]
\section{The general equation of first degree} \lipsum[3]
\section{Parallel and perpendicular lines} \lipsum[4]
\section{Angle between two lines} \lipsum[5]
\section{Distance from a point to a line} \lipsum[6]

\end{document}

在此处输入图片描述

相关内容