extsizes
package, which adds 14pt to the document class parameters, and configure everything else as written below:\ documentclass [ a4paper,14pt,russian ]{ extreport }
\usepackage { extsizes }
\usepackage { cmap } % pdf
\usepackage [ T2A ]{ fontenc }
\usepackage [ utf8 ]{ inputenc }
\usepackage [ russian ]{ babel }
\usepackage { pscyr }
\usepackage { graphicx } %
\usepackage { amssymb,amsfonts,amsmath,amsthm } %
\usepackage { indentfirst } %
\usepackage [ usenames,dvipsnames ]{ color } %
\usepackage { makecell }
\usepackage { multirow } %
\usepackage { ulem } %
\linespread { 1.3 } %
\renewcommand { \rmdefault }{ ftm } % Times New Roman
\frenchspacing
\begin { document }
\end { document }
The installation of \linespread{1.3}
(increase the line spacing by 1.3 times) approximately corresponds to what the Word world calls the “one and a half spacing”. The cmap
package includes in the resulting PDF (I use pdfLaTeX) a symbol table, so that it becomes possible to copy and search Cyrillic text in PDF without distorting the encodings. As for the source files, I store them in UTF-8 encoding; for your usual settings, change the value of the parameter during inputenc
. I will comment on the purpose of the remaining packages a little later, when I will discuss directly the writing of the diploma, and not the preamble with the design.fancyhdr
connect the fancyhdr
package, designed for the designation of page headers and footers, and turn off all defaults in it. The page becomes absolutely clean, except for the number ( \thepage
) in the right corner of the header.\usepackage { fancyhdr }
\pagestyle { fancy }
\fancyhf { }
\fancyhead [ R ]{ \thepage }
\fancyheadoffset { 0mm }
\fancyfootoffset { 0mm }
\setlength { \headheight }{ 17pt }
\renewcommand { \headrulewidth }{ 0pt }
\renewcommand { \footrulewidth }{ 0pt }
\fancypagestyle { plain }{
\fancyhf { }
\rhead { \thepage }}
\setcounter { page }{ 5 } % â„–5
It is worth noting that the first page of the chapter (chapter) uses the plain page style by default. It also has to be redefined in terms of fancyhdr
, so that numbers are put on the first pages of chapters (see the \fancypagestyle
).caption
package. Since I love detailed illustrations with several interconnected parts, we will also include the subcaption
package. According to the standard, the name of the picture is located below the picture, and the name of the table is above the table. You will have to keep track of these locations by yourself (see below), but the package can be prompted about this law so that it optimizes the allocation of empty space accordingly.\usepackage [ tableposition=top ]{ caption }
\usepackage { subcaption }
\DeclareCaptionLabelFormat { gostfigure }{ #2 }
\DeclareCaptionLabelFormat { gosttable }{ #2 }
\DeclareCaptionLabelSeparator { gost }{ ~---~ }
\captionsetup { labelsep=gost }
\captionsetup [ figure ]{ labelformat=gostfigure }
\captionsetup [ table ]{ labelformat=gosttable }
\renewcommand { \thesubfigure }{ \asbuk { subfigure }}
Here, using the \DeclareCaptionLabelFormat
new custom signature format is set up, which is then assigned to all the figures and tables in the document. Its first parameter # 1 is the standard text of the label (I preferred not to configure it as a separate line, but to write explicitly without using # 1), the second parameter # 2 is the figure / table number.\DeclareCaptionLabelSeparator
adjusts the separator between the caption label and its text itself, which you specify. In our case, this is the middle dash.subfigure
, these subparts must be numbered. It is accepted to number them in small letters in order - however, in our case it should be Cyrillic letters, not Latin! The Cyrillic representation of the counters (by analogy with the well-known representations of arabic
, roman
, latin
, etc.) has already been implemented in the babel
package. It is called, respectively, \asbuk
for small Cyrillic letters, and \Asbuk
for large.\begin { figure }[ ht ]
\centering
\begin { subfigure }[ b ]{ 0.3 \textwidth }
\centering
$$ \begin { array }{ l }
F \to x \ ;| \ ; y \ ;| \ ; (S) \\
T \to F \ ;| \ ; T \ast F \\
S \to T \ ;| \ ; S + T \\
\end { array } $ $
\ caption { }
\end { subfigure } %
\begin { subfigure }[ b ]{ 0.6 \textwidth }
\centering
\includegraphics [ scale=0.7 ]{ parseTree.png }
\ caption { }
\end { subfigure }
\ caption { (a) $G$ ;
() $x+y \ast y$ $G$ . }
\ label { fig_parsetree }
\end { figure }
And tables:\begin { table }[ ht ]
\ caption { }
\ label { tab_weight }
\centering
\begin { tabular }{ |c|c|c|c|c|c|c|c|c| }
\ hline \multirow { 2 }{ * }{ $x_i$ } & \multicolumn { 4 }{ c| }{ $x_j$ } &
\multicolumn { 2 }{ c| }{ } & \multicolumn { 2 }{ c| }{ } \\
\cline { 2-9 } & $X_1$ & $X_2$ & $X_3$ & $X_4$ & $w_i$ &
${ K_ \text { }} _i$ & $w_i$ & ${ K_ \text { }} _i$ \\
\ hline $X_1$ & 1 & 1 & 1.5 & 1.5 & 5 & 0.31 & 19 & 0.32 \\
\ hline $X_2$ & 1 & 1 & 1.5 & 1.5 & 5 & 0.31 & 19 & 0.32 \\
\ hline $X_3$ & 0.5 & 0.5 & 1 & 0.5 & 2.5 & 0.16 & 9.25 & 0.16 \\
\ hline $X_4$ & 0.5 & 0.5 & 1.5 & 1 & 3.5 & 0.22 & 12.25 & 0.20 \\
\ hline \multicolumn { 5 }{ |c| }{ : } & 16 & 1 & 59.5 & 1 \\
\ hline
\end { tabular }
\end { table }
It is worth noting the use of the \multirow
and \multicolumn
commands to create beautiful tables. They correspond to the HTML <table> parameters: rowspan
and colspan
, respectively. True, the first requires the connection of the multirow
package.titlesec
. According to the standard, chapters (the same sections) are written in the center, preceded by the line “Chapter N”, and the subsections and paragraphs are numbered within the chapter, and aligned by paragraph indent. Everything is typed in bold, with chapter headings also in upper case.\titleformat
configured by the \titleformat
. She has the following options:\MakeUppercase
works exclusively with one parameter, and it cannot be used like \bffamily
to switch the print format "from now and \usepackage { titlesec }
\titleformat { \chapter }[ display ]
{ \filcenter }
{ \MakeUppercase { \chaptertitlename } \thechapter }
{ 8pt }
{ \bfseries }{ }
\titleformat { \section }
{ \normalsize \bfseries }
{ \thesection }
{ 1em }{ }
\titleformat { \subsection }
{ \normalsize \bfseries }
{ \thesubsection }
{ 1em }{ }
%
\titlespacing* { \chapter }{ 0pt }{ -30pt }{ 8pt }
\titlespacing* { \section }{ \parindent }{ *4 }{ *4 }
\titlespacing* { \subsection }{ \parindent }{ *4 }{ *4 }
Notice the \parindent
in the indentation setting for subsections, forcing them to align by paragraph indent.\chapter
and \section
:\usepackage { geometry }
\geometry { left=3cm }
\geometry { right=1.5cm }
\geometry { top=2.4cm }
\geometry { bottom=2.4cm }
itemize
and enumerate
environments itemize
huge amount of space, creating a special inter-paragraph indent for them. To overcome this vicious habit, you can use the enumitem
package and give it the nolistsep
option, which disables all additional indents. However, enumitem
does not know anything about the new representation of asbuk
counters, which I mentioned above, so you need to point it at the command \AddEnumerateCounter
. Its third parameter is an example of the widest representation (the package will be oriented to this width when printing). For some reason (groundlessly) it seems to me that the widest letter of the Cyrillic alphabet in Times New Roman is exactly “m”. In any case, a person who creates a numbered list from “a” to “m” or below, deserves close attention of health authorities, as for me :)\usepackage { enumitem }
\ makeatletter
\AddEnumerateCounter { \asbuk }{ \@asbuk }{ ) }
\ makeatother
\setlist { nolistsep }
\renewcommand { \labelitemi }{ - }
\renewcommand { \labelenumi }{ \asbuk { enumi } ) }
\renewcommand { \labelenumii }{ \arabic { enumii } ) }
tocloft
package. I am not going to copy his documentation into the text of this note, it includes countless commands that literally customize every pixel in the table of contents. All these commands are substitutions in the style of "but type this between the text of the subsection title and the beginning of the dotted line." I use in the preamble 9 such commands, which, by and large, customize the look of the table of contents:\usepackage { tocloft }
\renewcommand { \cfttoctitlefont }{ \hspace { 0.38 \textwidth } \bfseries \MakeUppercase }
\renewcommand { \cftbeforetoctitleskip }{ -1em }
\renewcommand { \cftaftertoctitle }{ \ mbox { } \hfill \\ \ mbox { } \hfill { \footnotesize . } \vspace { -2.5em }}
\renewcommand { \cftchapfont }{ \normalsize \bfseries \MakeUppercase { \chaptername } }
\renewcommand { \cftsecfont }{ \hspace { 31pt }}
\renewcommand { \cftsubsecfont }{ \hspace { 11pt }}
\renewcommand { \cftbeforechapskip }{ 1em }
\renewcommand { \cftparskip }{ -1mm }
\renewcommand { \cftdotsep }{ 1 }
\setcounter { tocdepth }{ 2 } % — subsection
These commands set up all the necessary little things from the above list, except for one. Special sections will have to be treated in a special way.\newpage
knows the \newpage
command. Secondly, their title is drawn up in the center of the page in bold upper case letters ... and separated from the text by two lines. And finally, on top of this nonsense, special sections are in the table of contents at the chapter level, but they are not numbered and are not chapters. Feel like someone had nothing to do?\chapter*
is not suitable for obvious reasons: the chapters started by it are not included in the table of contents. In addition, you need to somehow arrange a double line break before the text - well, do not write the same \newline
manually every time?likechapter
), for a start it is worth defining the appropriate design command. Arrange the centering and capitalization of the section name - just spit. What I did - the \likechapterheading
prints the section name passed to it as it should.\newcommand { \empline }{ \ mbox { } \newline }
\newcommand { \likechapterheading }[ 1 ]{
\begin { center }
\ textbf { \MakeUppercase { #1 }}
\end { center }
\empline }
However, the section must also be included in the table of contents and aligned to the level of the chapter. And here it is already necessary to twist a little.\addcontentsline
. It has three parameters:tocloft
, which we set up a little higher, will type the word “Chapter” in front of the line. Only one way out - go to the end and define your own section level.\l@XXX
, where XXX is the name of the level (chapter, section, etc.). This command has two parameters - header text and page number. The purpose of the command is to print directly the table of contents with a dotted line, indents and all relying. If we want to define our own level view, we only need to define such a command for our level name. Then, in processing the command, \addcontentsline
will look at its second parameter, find among its definitions the corresponding \l@XXX
, where XXX is the substituted second parameter, and thus will finish printing the line in the table of contents.\l@likechapter
(simultaneously setting up for it the period between points in the dotted line, as in tocloft
), and to finish the definition of the \likechapter
:\ makeatletter
\renewcommand { \@dotsep }{ 2 }
\newcommand { \l @likechapter }[ 2 ]{ { \bfseries \@dottedtocline { 0 }{ 0pt }{ 0pt }{ #1 }{ #2 }}}
\ makeatother
\newcommand { \likechapter }[ 1 ]{
\likechapterheading { #1 }
\addcontentsline { toc }{ likechapter }{ \MakeUppercase { #1 }}}
\likechapter{}
.thebibliography
and the \bibitem
in their pure form. For their small setup, it was necessary to do the following:\usepackage [ square,numbers,sort&compress ]{ natbib }
\renewcommand { \bibnumfmt }[ 1 ]{ #1. \hfill } % —
\renewcommand { \bibsection }{ \likechapter { }} %
\setlength { \bibsep }{ 0pt }
Now the heading "List of references" is made out like likechapter, and is appropriately placed in the table of contents. The natbib
package beautifully compresses numbers when referring to something like "[2, 6-9]".lastpage
package, and in the text we simply refer to the new LastPage
tag LastPage
by it using \pageref*
:\usepackage { lastpage }
% ...
: \pageref * { LastPage } ~., ...
\AtEndDocument
). At the next compilation, it will be taken from the file, and the command determined by us will substitute the necessary number into the text. Thus, after two launches of pdfLaTeX, we get the text with the correct counter value.\newcounter { totfigures }
\newcounter { tottables }
\ makeatletter
\AtEndDocument { %
\addtocounter { totfigures }{ \value { figure }} %
\addtocounter { tottables }{ \value { table }} %
\immediate \write \@mainaux { %
\string \gdef \string \totfig { \number \value { totfigures }} %
\string \gdef \string \tottab { \number \value { tottables }} %
} %
}
\ makeatother
% ...
: \pageref * { LastPage } ~., \totfig ~., \tottab ~...
etoolbox
package. In it (among other things) there is a wonderful command \pretocmd
, which allows you to assign some additional code to the definition of any command in front. In this case, we want the value of the counter to change before any call \chapter
.\usepackage { etoolbox }
\pretocmd { \chapter }{ \addtocounter { totfigures }{ \value { figure }}}{ }{ }
\pretocmd { \chapter }{ \addtocounter { tottables }{ \value { table }}}{ }{ }
I note that manually changing the counter commands still has to be called twice. Once at the very end of the document (see above \AtEndDocument
). And once before the start of applications that are classified as chapters, but not called up using \chapter
(see below).\bibitem
will have to \bibitem
:\newcounter { totreferences }
\pretocmd { \bibitem }{ \addtocounter { totreferences }{ 1 }}{ }{ }
\AtEndDocument
(see above):\string \gdef \string \totref { \number \value { totreferences }} %
and you can write in the text " \totref
~ sources ..."tocloft
so that it printed the word “Chapter” for the chapter, and the word “Appendix” for the application, despite the fact that it is stated as \chapter
. At the same time, printing the necessary word in the title itself is obtained without any problems, thanks to the command \chaptertitlename
defined in the package titlesec
.\paragraph
in the title is identical to \chapter
, and add the corresponding line to the table of contents at the level of likechapter.\usepackage [ title,titletoc ]{ appendix }
\titleformat { \paragraph }[ display ]
{ \filcenter }
{ \MakeUppercase { \chaptertitlename } \thechapter }
{ 8pt }
{ \bfseries }{ }
\titlespacing* { \paragraph }{ 0pt }{ -30pt }{ 8pt }
\newcommand { \append }[ 1 ]{
\clearpage
\stepcounter { chapter }
\paragraph { \MakeUppercase { #1 }}
\empline
\addcontentsline { toc }{ likechapter }{ \MakeUppercase { \chaptertitlename ~ \Asbuk { chapter }\ ;#1 }}}
\begin { appendices }
\renewcommand \thechapter { \Asbuk { chapter }}
\setcounter { chapter }{ 0 }
\append { }
...
\end { appendices }
\Asbuk
taken, since applications are usually numbered in capital Cyrillic letters.pdfpages
.fancyhdr
so that it works on the included pages. Secondly, the first page of the application contains not only the first two slides of the presentation, but also the title “Appendix A”. Both the first and the second difficulty are solved by the parameter pagecommand
present in the options list of our main team \includepdf
. Ready source code:\usepackage { pdfpages }
% ...
\includepdfset { nup=1x2,frame=true,delta=10mm 10mm,noautoscale=true }
\includepdf [ pages=1-2,scale=0.55,offset=10mm -20mm,pagecommand={ \append { }} ]{ defence.pdf }
\includepdf [ pages=3-,scale=0.55,offset=10mm 0mm,pagecommand={ \fancyhead [ R ]{ \thepage }}]{ defence.pdf }
listings
. He just needs a little help: specify in which font to print the code (option basicstyle
), ask to transfer the words in lines (option breaklines
), and correct the set of keywords of the programming language (option morekeywords
) - it recognizes C # 2.0, and I wrote in C # 4.0. The package will cope with everything else itself, even load the source code from the file next to it.\usepackage { listings }
%...
\append { }
\lstset { language= [ Sharp ] C,
morekeywords= { yield,var,get,set,from,select,partial } ,
breaklines=true,
basicstyle= \footnotesize \ttfamily }
\linespread { 1 } %
\lstinputlisting { MyCoolProjectClass.cs }
chapter_ProgramSynthesis
. This folder will chapter_ProgramSynthesis.tex
contain a file containing the assembly of subsections of the chapter, the actual files sec_XXX.tex
with specific subsections, and all the necessary additional materials (for example, pictures).import
. It has a great command \subimport
that takes two parameters - a folder that temporarily becomes a file search path, and a directly include file. To include chapters in a diploma, we define an auxiliary team, and we can now easily refer to chapters by name.diploma.tex
:\usepackage { import }
\newcommand { \includechapter }[ 1 ]{ \subimport { chapter_#1/ }{ chapter_#1 }}
\newcommand { \inputintro }{ \ input { sec_Intro } \newpage }
% ...
\includechapter { ProgramSynthesis }
chapter_ProgramSynthesis/chapter_ProgramSynthesis.tex
:\chapter { PROGRAM SYNTHESIS }
\inputintro
\ input { sec_Basics }
\ input { sec_Stages }
\ input { sec_Example }
\ input { sec_Conclusions }
sec_Basics.tex
and others are in the same subfolder chapter_ProgramSynthesis
. The link to the pictures from the same subfolder occurs directly - see the example of the definition of the illustration at the beginning of the article. I determined the\inputintro
from pure perfectionism: since I always call the “Introduction” subsection sec_Intro.tex
and start a new page after it, why write duplicate code? :-)Source: https://habr.com/ru/post/144648/
All Articles