Επέκταση στο "γράφοντας βιβλίο"

Συμπληρωματικοί Οδηγοί από αυτούς που αναφέρονται στο blog.

Συντονιστής: Community Bot

Κανόνες Δ. Συζήτησης
Αν θα θέλατε να δημοσιεύσετε έναν οδηγό σχετικά με κάποιο θέμα παρακαλώ επικοινωνήστε μαζί μας . Αν θέλετε να συζητήσετε κάποιον οδηγό ανοίξτε ένα νέο θέμα στον αντίστοιχο φάκελο.
Κλειδωμένο
Άβαταρ μέλους
Community Bot
Robot
Δημοσιεύσεις: 53
Εγγραφή: Πέμ Απρ 13, 2017 10:06 pm

Επέκταση στο "γράφοντας βιβλίο"

Δημοσίευση από Community Bot »

Είδαμε στο άρθρο εδώ τα βασικά στοιχεία ενός βιβλίου. Για παράδειγμα είδαμε πώς να γράφουμε ένα κεφάλαιο ή πώς μία ενότητα είτε αυτά είναι αριθμημένα είτε όχι. Τέλος, είδαμε πώς να βάζουμε ένα μη αριθμημένο κεφάλαιο στο πίνακα περιεχομένων.

Ένα βιβλίο όμως έχει παραπάνω πράγματα. Για παράδειγμα , μπορεί να μη σας αρέσει καθόλου η προεπιλεγμένη δομή του πίνακα περιεχομένων και να θέλετε να δημιουργήσετε κάτι δικό σας.

1. Διάφορα Πρότυπα για το Πίνακα Περιεχομένων


Τα περισσότερα styling του toc απαιτούν το πακέτο tocloft που είναι εγκατεστημένο τόσο στο TeX Live 201x. αλλά και στο MikTeX. Ακολουθούν μερικά παραδείγματα μαζί με τους κώδικες που τα παράγουν:

1.\documentclass{book}
\usepackage{xcolor}
\usepackage{framed}
\definecolor{myred}{RGB}{127,0,0}
\definecolor{myyellow}{RGB}{169,121,69}
\renewenvironment{leftbar}{%
\def\FrameCommand{{\color{myyellow}\vrule width 2pt depth 6pt} \hspace{10pt}}%
\MakeFramed {\advance\hsize-\width \FrameRestore}}%
{\endMakeFramed}
\makeatletter
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addtocontents{toc}%
{%
{\protect\parbox{3.5em}{\hfill\Huge\color{myred}\bfseries\thepage}}%
\protect\hspace*{.5em}
\protect\parbox{\dimexpr\linewidth-4em\relax}{%
\protect\begin{leftbar}
{\scshape\small\chaptername~\thechapter}\\\sffamily#1%
\protect\end{leftbar}}\par\noindent
}%
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi}
\makeatother
\begin{document}

\tableofcontents

\chapter{Beginning to learn design with \LaTeX}
\chapter{Beginning to learn design with HTML}
\setcounter{page}{13}% just for the example
\chapter{Beginning to learn design with HTML and some other text to span more than one line in the ToC}

\end{document} και ο κώδικας μας δίδει

Εικόνα

και λίγο styling δε βλάπτει
\documentclass{book}
\usepackage{xcolor}
\usepackage{framed}
\usepackage{tikz}
\usepackage{titletoc}
\usepackage{etoolbox}
\usepackage{lmodern}

% definition of some personal colors
\definecolor{myred}{RGB}{127,0,0}
\definecolor{myyellow}{RGB}{169,121,69}

% command for the circle for the number of part entries
\newcommand\Circle[1]{\tikz[overlay,remember picture]
\node[draw,circle, text width=18pt,line width=1pt] {#1};}

% patching of \tableofcontents to use sans serif font for the tile
\patchcmd{\tableofcontents}{\contentsname}{\sffamily\contentsname}{}{}
% patching of \@part to typeset the part number inside a framed box in its own line
% and to add color
\makeatletter
\patchcmd{\@part}
{\addcontentsline{toc}{part}{\thepart\hspace{1em}#1}}
{\addtocontents{toc}{\protect\addvspace{20pt}}
\addcontentsline{toc}{part}{\huge{\protect\color{myyellow}%
\setlength\fboxrule{2pt}\protect\Circle{%
\hfil\thepart\hfil%
}%
}\\[2ex]\color{myred}\sffamily#1}}{}{}

%\patchcmd{\@part}
% {\addcontentsline{toc}{part}{\thepart\hspace{1em}#1}}
% {\addtocontents{toc}{\protect\addvspace{20pt}}
% \addcontentsline{toc}{part}{\huge{\protect\color{myyellow}%
% \setlength\fboxrule{2pt}\protect\fbox{\protect\parbox[c][1em][c]{1.5em}{%
% \hfil\thepart\hfil%
% }}%
% }\\[2ex]\color{myred}\sffamily#1}}{}{}
\makeatother

% this is the environment used to typeset the chapter entries in the ToC
% it is a modification of the leftbar environment of the framed package
\renewenvironment{leftbar}
{\def\FrameCommand{\hspace{6em}%
{\color{myyellow}\vrule width 2pt depth 6pt}\hspace{1em}}%
\MakeFramed{\parshape 1 0cm \dimexpr\textwidth-6em\relax\FrameRestore}\vskip2pt%
}
{\endMakeFramed}

% using titletoc we redefine the ToC entries for parts, chapters, sections, and subsections
\titlecontents{part}
[0em]{\centering}
{\contentslabel}
{}{}
\titlecontents{chapter}
[0em]{\vspace*{2\baselineskip}}
{\parbox{4.5em}{%
\hfill\Huge\sffamily\bfseries\color{myred}\thecontentspage}%
\vspace*{-2.3\baselineskip}\leftbar\textsc{\small\chaptername~\thecontentslabel}\\\sffamily}
{}{\endleftbar}
\titlecontents{section}
[8.4em]
{\sffamily\contentslabel{3em}}{}{}
{\hspace{0.5em}\nobreak\itshape\color{myred}\contentspage}
\titlecontents{subsection}
[8.4em]
{\sffamily\contentslabel{3em}}{}{}
{\hspace{0.5em}\nobreak\itshape\color{myred}\contentspage}


\begin{document}

\tableofcontents

\part{Designing with \LaTeX}

\chapter{Beginning to learn design with \LaTeX}
\section{This is a test section}
\subsection{Long subsection title and some other text to span more than one line}

\newpage\setcounter{page}{123}% just for the example

\part{Designing with HTML}

\chapter{Beginning to learn design with HTML and some other text to span more than one line in the ToC}
\section{This is a test section}
\subsection{Long subsection title and some other text to span more than one line}

\end{document} που μας δίδει

Εικόνα

2.
\documentclass{book}

\makeatletter
% Basically the same as for `\l@section` etc, just `\@nodottedtocline` instead of `\@dottedtcline`:
\newcommand*\l@chapterinfo{\@nodottedtocline{0}{0.0em}{1.5em}}
\newcommand*\l@sectioninfo{\@nodottedtocline{1}{1.5em}{2.3em}}
\newcommand*\l@subsectioninfo{\@nodottedtocline{2}{3.8em}{3.2em}}
\newcommand*\l@subsubsectioninfo{\@nodottedtocline{3}{7.0em}{4.1em}}
\newcommand*\l@paragraphinfo{\@nodottedtocline{4}{10em}{5em}}
\newcommand*\l@subparagraphinfo{\@nodottedtocline{5}{12em}{6em}}

% Copied from the book class macro `\@dottedtocline`. Removed the dots and page number
\def\@nodottedtocline#1#2#3#4#5{%
\ifnum #1>\c@tocdepth \else
\vskip \z@ \@plus.2\p@
{\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
\parindent #2\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima #3\relax
\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
{#4}\nobreak
\leaders\hbox{$\m@th
\mkern \@dotsep mu\hbox{\,}\mkern \@dotsep
mu$}\hfill
\nobreak
\hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor }%
\par}%
\fi}

\makeatother

\def\chapterinfo#1{%
\addcontentsline{toc}{chapterinfo}{%
\noexpand\numberline{}#1}%
}
\def\sectioninfo#1{%
\addcontentsline{toc}{sectioninfo}{%
\noexpand\numberline{}#1}%
}
\def\subsectioninfo#1{%
\addcontentsline{toc}{subsectioninfo}{%
\noexpand\numberline{}#1}%
}
% same for subsubsection, etc. ...

\begin{document}
\tableofcontents

\chapter{AAA}
\chapterinfo{A very long text, a very long text, a very long text, a very long text, a very long text, a very long text, a very long text, a very long text}

\section{aaa}
\sectioninfo{A very long text, a very long text, a very long text, a very long text, a very long text, a very long text, a very long text, a very long text}

\subsection{1111}
\subsectioninfo{A very long text, a very long text, a very long text, a very long text, a very long text, a very long text, a very long text, a very long text}
\end{document} που δίδει

Εικόνα

3. Ένα τελευταίο template είναι το ακόλουθο:
\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{kpfonts}
\usepackage[tmargin=2cm,rmargin=3.8cm,lmargin=3.8cm,bmargin=2cm]{geometry}
\usepackage{tikz}
\definecolor{doc}{RGB}{0,60,110}
\usepackage{titletoc}
\contentsmargin{0cm}
\titlecontents{chapter}[0pc]
{\addvspace{30pt}%
\begin{tikzpicture}[remember picture, overlay]%
\draw[fill=doc!30,draw=doc!30] (-4,-.1) rectangle (-1,.5);%
\pgftext[left,x=-3.7cm,y=0.2cm]{\color{white}\Large\sc\bfseries chapter\ \thecontentslabel};%
\end{tikzpicture}\color{doc!40}\large\sc\bfseries}%
{}
{}
{\;\titlerule\;\large\sc\bfseries Page \thecontentspage
\begin{tikzpicture}[remember picture, overlay]
\draw[fill=doc!25,draw=doc!20] (2pt,0) rectangle (6,0.1pt);
\end{tikzpicture}}%
\titlecontents{section}[2.4pc]
{\addvspace{1pt}}
{\contentslabel[\thecontentslabel]{2.4pc}}
{}
{\hfill\small \thecontentspage}
[]
\titlecontents*{subsection}[4pc]
{\addvspace{-1pt}\small}
{}
{}
{\ --- \small\thecontentspage}
[ \textbullet\ ][]

\makeatletter
\renewcommand{\tableofcontents}{%
\chapter*{%
\vspace*{-20\p@}%
\begin{tikzpicture}[remember picture, overlay]%
\pgftext[right,x=15cm,y=0.2cm]{\color{doc!30}\Huge\sc\bfseries \contentsname};%
\draw[fill=doc!30,draw=doc!30] (13,-.75) rectangle (20,1);%
\clip (13,-.75) rectangle (20,1);
\pgftext[right,x=15cm,y=0.2cm]{\color{white}\Huge\sc\bfseries \contentsname};%
\end{tikzpicture}}%
\@starttoc{toc}}
\makeatother
\begin{document}
\tableofcontents
\chapter{Questions of Design}
\section{(title section 1)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\section{(title section 2)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\chapter{Questions of Drawing}
\section{(title section 1)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\section{(title section 2)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\chapter{Questions of Technique}
\section{(title section 1)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\section{(title section 2)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\end{document} με αποτέλεσμα

Εικόνα

2.Πίνακας Περιεχομένων στα κεφάλαια

Μπορείτε να εισάγετε έναν μίνι πίνακα περιεχομένων μέσα στα υπάρχοντα κεφάλαια πριν αυτά αρχίσουν. Για παράδειγμα ας δούμε την επόμενη εικόνα.

Εικόνα

Για να το δημιουργήσουμε βάζουμε τον ακόλουθο κώδικα:
\usepackage{minitoc}
...
\dominitoc
\tableofcontents
...
\chapter{...}
\minitoc
Είμαι ένας ανενεργός λογαριασμός για τις απαιτήσεις της κοινότητας.
Άβαταρ μέλους
Community Bot
Robot
Δημοσιεύσεις: 53
Εγγραφή: Πέμ Απρ 13, 2017 10:06 pm

Re: Επέκταση στο "γράφοντας βιβλίο"

Δημοσίευση από Community Bot »

Τα παραπάνω templates αλλά και οι κώδικες που τα παράγουν έχουν παρθεί από τον tex.stackexchange.com . Η εκεί σελίδα περιέχει και άλλες μορφοποιήσεις που μπορεί να ενδιαφέρουν τον αναγνώστη. \

Προσοχή, το εκεί site είναι στα αγγλικά.
Είμαι ένας ανενεργός λογαριασμός για τις απαιτήσεις της κοινότητας.
Κλειδωμένο

Μέλη σε σύνδεση

Μέλη σε αυτήν τη Δ. Συζήτηση: Δεν υπάρχουν εγγεγραμμένα μέλη και 31 επισκέπτες