How to write a physics book in LaTeX. Article 1

This is my first article on Habré.



Chapter 1. Introduction



1.1 Let me introduce myself and why I am writing this I



am a researcher, physicist. Recently published a book on spectroscopy with 880 pages and a weight of 1560 grams. I have been writing this book for 9 years, while giving lectures on its contents. It took a lot of my time, which is natural. What is not natural is that a huge part of the time spent was spent on design, that is, on learning the Latech language. And this despite the fact that I have been writing on Latekh all my life, personally wrote and published about 50 articles in different publishing houses.



In this article (a continuation is planned, but this is how it will go) I would like to share with my readers my knowledge gained at great expense. If the reader writes only articles, then he does not really need my article - it contains what the authors of large books need.



After the publication of the book (so far, alas, only in Russian), I had a great desire to write another book "How to write a book on physics in Latekh"



1.2 And why on Habré?



If there was a Main Forum for Latech users in Russia, I would be there. But he is not, alas. Whether there is in the world - I don't know. There are very decent forums like latex.org/forum or tex.stackexchange.com , but there are mostly questions and answers.



There are good authors in Russia, but there is no large well-known forum. It's a shame.



An acquaintance student of St. Petersburg State University recently told me that they are forced to write texts in Latekh, but they do not recommend books or good sites. With this approach, our crocodiles may take off, but only very low.



1.3 Why Latech?



I just don't know other editors. Never in my life wrote a single serious work in Word or OpenOffice. Therefore, I cannot compare editors. Latech is like an old wife. There was love, there were quarrels, everything was ... But without him I can no longer.



There is often an opinion that Latech formats text better, easier and more beautiful than any other editor. That he kind of says to the author: "Step aside, you still don't understand anything about the design of the text, let a professional work."



I think this is only partially true. I spent a lot of time designing the text, and it's very sad. I am not going to describe the rules for working with Latech, there are good books for this, (*) quite the opposite - I am going to write about what these books do not have.



There are a lot of tricky techniques in the design of the text and the creation of drawings, which I want to describe at least briefly if my text interests someone here on Habré.



1.4 Do I have a goal



I, of course, understand that an insignificant number of people write in Latech. As a rule, mathematicians and physicists, and even then not all. Of the authors writing in Latech, the share of those who write books is very, very small. Finally, the writing in Russian is negligible.



The logic of this note is not to give the reader a broad view of the use of Latech for book writing. I do not have a sufficient outlook for this: I am sure that whoever digs everywhere does not dig deeply. The logic of the note is as follows: "I do not know which paths lead where in our dense forest. I walked through a dense forest along one path, and I am going to tell you about it."



If we talk about trends, then the widespread introduction of scientometrics in Russia, that is, the Hirsch index (and others like him) and the number of citations, should completely destroy a scientific book. I mean, first of all, taking this scientometrics into account when appointing to positions, as well as when distributing grants and other types of funding. Let me remind you that books are not counted in the Hirsch index at all.



If our scientific supervisors are consistent in everything, in the future they should prohibit the Russian language, especially the written one, for writing books - punish, and for writing books in Russian - severely punished, up to and including dismissal. For the extremely ineffective use of official working time.



Therefore, my work, this book, sometimes seems to me to be something stupid and unnecessary. But it's boring to live without eccentrics (fools?) ...



Besides, here, on Habré, people often write articles about all kinds of junk, like gramophone records or cassette recorders. Why is my topic worse?



1.5 Best Modern Books



In the process of writing my textbook, I went through a huge number of foreign books and textbooks, and came to the conclusion that the best textbooks in my field were written by Atkins (PW Atkins ) from Oxford with various coauthors. See, for example, " Molecular Quantum Mechanics " (2005). There are also very good books by Demtroder ( W. Demtroder, "Laser spectroscopy: basic concepts and instrumentation", 2003; Electrodynamics and Optics ", 2019; ... )



What is interesting about Demtroder - he thanks the special service that helped him to arrange the book in Latehe: There is such a service in Germany, but not in Russia.



Moreover, these books are the best not so much in content as in design. The naked eye can see that they are all made in Latech with the active use of the TikZ package. As a result, I got the feeling that the Latech - TikZ combination is the best way to create a book designed at the best world level. That is why TikZ was heavily used in my book (even where you can do without it).



1.6 The ideal book of the future



I would like to speculate about the ideal book of the future. That is, about where scientific publishing will inevitably come (well ... should come). That is, about what we, scientists, should strive for in order to increase our competitiveness and attractiveness.



Naturally, the book of the future will exist in two versions: paper and electronic. In addition, it will be colored. Moreover, not only drawings will stand out in color.



The clear modern division of content into text, pictures, tables and formulas will be a thing of the past. For example, there is a need for arrows that connect some places in texts, figures, tables, etc. Why separate figures and tables? Why can't I place pictures inside the table or vice versa? Isn't it more convenient sometimes to have a mixture of them?



Figure 1 shows two pages of my book (online version) to make it clear that text and graphics can flow smoothly into each other.





Figure: 1. An example of the design of my book. The flow of the table into the picture is shown



Other ideas, offhand.



  1. , , , .. (, , ).
  2. . . .
  3. — . .
  4. , , . , — , .

    - - " ". ?
  5. , : . : TikZ.


Of course, all these dreams bloomed in my head only until I met a living editor, who considers all this expensive and unnecessary whim, but that's another topic.



1.7 About compilers, editors, Latech dialects

This is a very large and painful topic.



I use the Windows / MikTeX / WinEdt bundle (= OS / compiler / editor), but even within this bundle there is a large selection of versions.



I think the WinEdt editor is the best (although sometimes I also use TexStudio), but after version 5.6 it began to evolve in an unpleasant way for me (I do not describe the WinEdt hack here, but this is not a problem for any version).



For example, I am conservative and blind, so I only recognize my syntax coloring, not the one suggested by the creator of WinEdt, see fig. 2 and fig. 3.





Figure: 2. Syntax coloring in WinEdt v.10





Fig. 3. My syntax coloring in WinEdt v.5.6



But the main nuisance is that new compilers pretend to be able to work with eight-bit fonts in UTF-8 encodings, for which dialects like LuaLatex, XeLatex, etc. have been developed and actively introduced. It seems like progress, that these new dialects are able to create text with any typeface, even with Old Church Slavonic. But how many costs are there ...



One of my main complaints is that if I transfer some text from the Internet, there will probably be a mixture of encodings, the editor will not show some of the characters to me, and the compiler will give an error that will be difficult to find.



For Russian-language text, I recognize only seven-bit fonts and ANSI / Windows1251 encoding, and I transfer texts from the Internet not directly, but through some simplified editor (for example, Notepad ++), in which you can configure all encodings as needed.



And only at the very end, doing the final formatting of the text, you can switch to UTF-8. This is a lot of work.



The only simple improvement to Latech's font that does not affect text formatting in any way is the transition from CM to CM-super.



Let me remind you that you can always play with the formatting settings, for example,

\clubpenalty=400   %   --     .  = 300,   = 10000.
\widowpenalty=400  %%      ,      .
\righthyphenmin=2 %    .   Babel,    .
\tolerance=500   %max=10000, default=200 (    ).
%  ,  !
\looseness=-1 %       .
\hfuzz=2.5pt %        2.5 pt.


Chapter 2. Your standards



2.1 Tips for a Newbie Writer



Here's a list of basic tips for a beginner long text writer. Large text is text that is very tedious to flip through, it can only be edited with the search and replace commands.

As the military people would put it, every piece of advice is "written in blood." Well, okay, not with blood ... But the time spent, nerves, headache ... At first it seems that then there will be time to fix everything. And then it turns out that reworking a book to suit the tastes of the editorial office is a very time-consuming business.



2.1.1 Find out the page format of your future book and include it in the preamble from the very beginning. This will save you the painful reformatting. From the very beginning, specify in the preamble the final page layout (headers, footers, margins, etc.), as well as the size and type of font.



For example, the format of my book is 70x100 1/16, and therefore the preamble contains the following settings:

\special{papersize=170mm,240mm}
\textheight 187mm % 200-(12+25)*0.35146 = 186.99598
\textwidth 130mm
\headheight13.6pt % = 0.48 mm
\oddsidemargin -5.4mm
\evensidemargin -5.4mm
\topmargin -5.4mm
\usepackage{setspace}
\singlespacing


here is the command

\singlespacing
sets the entire document to single spacing, and is itself part of the setspace package.

It should be understood this way. The margins, top and bottom, are 20 mm. Therefore, an area of ​​130 * 200 mm is available. Recording

\topmargin -5.4mm


means that the distance from the top of the header h to the top of the page is h = 1 inch + topmargin = 2 cm, which is what you want. The width of the text is 130 mm, but from the height of 200 mm, subtract the height of the header (headheight) and the distance from the header to the text (headsep).

It is understood that there are three more commands:

\voffset=0 \headheight12pt \headsep25pt % 1 pt = 0.3528 


and the general formula:

240 = y-papersize = 2 * (2.54 cm + topmargin) + y-textheight + headheight + headsep = 40+ 186.99598 + (12 + 25) * 0.35146 mm.



Everything, it would seem, is clear. But the compiler gives the message on every page:

Package Fancyhdr Warning: \ headheight is too small (12.5pt):

Make it at least 13.59999pt.

We now make it that large for the rest of the document.

This may cause the page layout to be inconsistent, however.




So we are redoing. Now
\headheight13.6pt


It is useful to remember that native, that is, built-in Latech fonts are 10, 11 and 12 pt. For other sizes, you need to connect special packages. I wanted the font to be smaller so that more text would fit on the page. But in the editorial office I was told that 11 pt Latech font looks like 10.5 pt in Microsoft Word. And so I chose 11 pt. But in vain. It was necessary 10 pt, as they do in most publishing houses abroad.



A large, serious publishing house has its own style, and then the author does not need to think, but this (usually) does not apply to Russia.



I wrote and thought that it might be good that ours rarely show off their style. Most recently submitted an article to AIP Conference Proceedings magazine, his document style

\documentclass[aip,cp,amsmath,amssymb,reprint]{revtex4-2}


and I get the answer: "... Your design does not match ... Email addresses should be right after the authors' names, and not in footnotes ..."



And how can it not match if I took the style and the document template from their website? In the course of the correspondence with the support service, it turned out that, as they think, some of my packages are outdated, and therefore it is better for me to compile my articles on their website, the service www.overleaf.com/latex



First of all, I hate Can these fashionable attempts to simplify my computer to an interface to programs located on the Internet, and secondly, how creative do you need to be to tie the style of articles to some deeply hidden settings of my compiler?



Change the style of the magazine (cp), change the style of the publisher (revtex4-2), but why make them compiler-dependent ?!



2.1.2 Font selection



The font in the editor must be monospaced (Consolas, Lucida Console, Courier, Courier New, ...), and the text editor must easily switch between block and line modes. This allows you to rearrange columns in tables if they are properly prepared.



Another example. When I need to leave only one file for compilation (one chapter out of twenty), I select the column of% signs and move it to the beginning of the paragraph. Then I use my hands to remove the% sign in front of the file I need, and as a result, all the files turn out to be comments, except for the desired one.



2.1.3 A person's visual memory works well. He recognizes familiar passages in the text and it is a sin not to use this ability. So my standard is one sentence = one paragraph. No automatic line alignment (disable Wrap). As a result, the position of the text on the line will not change if I change something in the preceding sentences.



2.1.4 The name of the file with the picture must match its label. This is convenient, and also saves one variable in the macro calling the drawing.



2.1.5 The name of the article (tag) is compiled according to the standard. It is terribly convenient, but there are no comrades in taste and color.

My standard: reference Purcell46_681 means (author) - (publication year) - (page number).



2.1.6 Syntax coloring. For some reason it is very important for me. An example of my coloring and the standard WinEdt coloring are shown in Fig. 2. The

coloring of the syntax from the manufacturer WinEdt, in my opinion, is poor and does not correspond to my tastes.

The correct (my) coloring principles are as follows:

- comments: faint italic text on a gray background,

- link text (\ ref, \ cite): bright background, but different for references to literature and equations,

- brackets: bold, bright background, the back bracket must be underlined,

- latech commands (\ begin): light background,

- service characters ($, _,): bold and highlighted in the text with color,

- end of line in the table (\\): bold white on black background.

2.1.7 The simplest "correct" structure of a book is two directories: one is for the text of the book, the other is a workshop for making vector drawings in the TikZ package.

Inside each there is a \ Figs subdirectory for finished drawings.

I will not talk about the workshop in this article.



Chapter 3. Your designations



3.1 Small replacements

that I am used to calling macros, although this is probably wrong.



Once upon a time, 30 years ago, I was very impressed that I can fill in mathematical formulas at machine-gun speed without looking at the monitor. I still like it. But I especially fell in love with typing texts using my designations. All of them, of course, are collected in a preamble file.



Can abbreviations always be entered? No, unfortunately, not always. The compiler does not want to understand many of them. For example, I have not yet found an abbreviation for terribly useful environments like
\begin{split}--\end{split}, \begin{align}--\end{align}




The simplest examples.

\newcommand*{\BE}{\begin{equation}} %
\newcommand*{\EN}{\end{equation}} %
\newcommand*{\BEA}{\begin{subequations} \begin{eqnarray}} %
\newcommand*{\ENA}{\end{eqnarray} \end{subequations}} 


Stuff text like

\begin{equation}


very lazy. Therefore, I introduced the abbreviation - \ BE long ago. Why with big letters? Because about 30 years ago, the Dos Latech (= EmTex) did not want to work with small letters.

In English, the first paragraph begins without a red line. To override this rule, the \ hs command is usually used:

\newcommand*{\hs}{\hspace*{\parindent}}


Cancel automatic formula numbering:

\newcommand*{\nn}{\nonumber}


For the list of authors, an analogue of Russian , etc .:

\newcommand*{\ea}{{\it et al\/}\xspace}


This is especially useful if you want to print et al in italics. Pay attention to the \ xspace command, it understands whether you need to make a space (if words go further) or not (if punctuation marks go further).



If you often write chemical formulas, then substitutions like

\newcommand*{\1}{$_1$}
\newcommand*{\2}{$_2$}
\newcommand*{\3}{$_3$}
\newcommand*{\4}{$_4$}
\newcommand*{\5}{$_5$}
\newcommand*{\6}{$_6$}
\newcommand*{\7}{$_7$}
\newcommand*{\8}{$_8$}
\newcommand*{\9}{$_9$}


For example, instead of C $ _2 $ H $ _5 $ OH, I write C \ 2H \ 5OH. It's a little bit faster.



To insert text into math formulas, I use

\newcommand*{\T}[1]{\text{#1}}


In my science, wave numbers are often used (these are frequency units, they are equal to reciprocal centimeters),

\newcommand*{\ic}{cm $^{-1}$\xspace}


There were times when I cut literally everything. For example, if I was too lazy to write words like "photodissociation", I would enter the abbreviation \ pd.

If you need to write numbers, then I made abbreviations like

\newcommand*{\po}[1]{$\times \! $10$^{#1}$} % *10(-n)
\newcommand*{\vp}[2]{#1$ \times \! $10$^{#2}$\xspace} % v*10(n)
\newcommand*{\ve}[2]{#1$\pm$#2\xspace} % v+-e
\newcommand*{\vep}[3]{$(#1 \pm #2)\times \! 10^{#3}$\xspace} % (v+-e)*10^n


For example, \ vep is the number v with an error of e multiplied by 10 to the power of p , i.e. \ vep {v} {e} {p} $ = (v \ pm e) \ times10 ^ {p} $.



3.2 Referring to tables and figures

A little about something else: Latech reference to the \ ref reference does not distinguish figures, tables, sections, ... When there are a lot of them, it is annoying and can lead to confusion. It turned out that it is very convenient to format links in the form \ fref {fig: name}, \ fref {tab: name}, \ fref {sec: name}, ... which can be done using the fancyref package.

Not only will you yourself understand what the link refers to, but it also becomes possible to design them in different ways (in font and color).



3.3 Large replacements

The style gradually developed - for complex manipulations, never use Latech standards directly, but only through macros. It is very convenient when you have to edit everything in order to please the whims of the editorial board.

Here is a macro for creating a picture that is wrapped around with text:

\newcommand*{\EpsWrapD}[7]{%
\begin{wrapfigure}[#5]{#3}{#2 \textwidth} % #3=l,r,L,R
\begin{center} \sffamily
\includegraphics*[width= #2 \textwidth ]{#1} % 1-    ,
% 2-  (   )
\vspace{-#7mm} % #7:       
\caption{\label{fig:#1}#4} % #4 -   
\vspace{-#6pt}
\end{center}% #6:          \end{wrapfigure}}


Here is a macro for creating a table that is wrapped in text:

\newcommand*{\TableBE}[5]{
\begin{table}[#1] %\captionabove
\vspace*{-#5mm}
\centering \sffamily \caption{\label{tab:#2}#3} \begin{tabular}{#4} \toprule }

\newcommand*{\TableEN}[3]{
\bottomrule \end{tabular}
\vspace{-#2mm} \small \begin{flushleft} #1 \end{flushleft}
\vspace{-#3mm}
\end{table}}


And here is the text of a simple table

\TableBE{H}{RS_Ham_2pi}{\TableBE{H}{RS_Ham_2pi}{     $^2\Pi $}{G LL}{2} $^2\Pi $ }{G LL}{2}
\CR & |^2\Pi_{1/2} JM_J \pm \rangle & |^2\Pi_{3/2} JM_J \pm \rangle \\
\midrule
|^2\Pi_{1/2} JM_J \pm \rangle & B[J_{\perp}^2+1] -A/2 & -B J_{\perp} \\
|^2\Pi_{3/2} JM_J \pm \rangle & -B J_{\perp} & B[J_{\perp}^2-1] +A/2 \\
\TableEN{}{0}{0}


and its compiled form:







Macro \ TableBE has 5 variables:

# 1) how and where to put the table. For example, h = "I would like a table here",

h! = "I really want a table here", H = "I want a table right here and that's it",

t! = Put ​​the table at the top of the page,

# 2) link to the table,

# 3) table title.

# 4) Description of columns. For example, {G LL} means: left alignment, math mode, first column to color.

# 5) Aesthetics: Sometimes you want to reduce the space between the header and the table.

The \ TableEN macro has 3 variables:

# 1) text under the table.

# 2) Aesthetics: sometimes you want to reduce the distance between the text and the table.

# 3) Aesthetics: sometimes you want to reduce the distance between the table and the following text.



It is often convenient to create macro families. For example, I have a main macro to insert a picture into text.

\newcommand*{\RisEpsLarge}[7]{
\begin{figure}[#5] \begin{center}
\includegraphics*[width= #2 \textwidth,#6]{#1} %#6: scale=2, bb=10 20 100 200
\vspace{-#3mm}
\sansmath
\caption{ \label{fig:#1}#4}
\vspace{-#7mm}
\end{center} \end{figure}
}


It has 7 parameters, which is a lot for me. Therefore, I created the macro family shown below. The main idea is to reduce the number of parameters so that you can think as little as possible when creating a table. The reader will easily guess that they differ in the rule of the arrangement of the picture and its rotation by + -90 degrees (sometimes it is necessary, because this clever fool, Latech, has its own ideas of how to rotate the drawings).

\newcommand*{\RisEpsPos}[5]{\RisEpsLarge{#1}{#2}{#3}{#5}{#4}{angle=0}{0}}

\newcommand*{\RisEps}[4]{\RisEpsLarge{#1}{#2}{#3}{#4}{!tbhp}{angle=0}{0}}
\newcommand*{\RisEpsTop}[4]{\RisEpsLarge{#1}{#2}{#3}{#4}{!t}{angle=0}{0}}
\newcommand*{\RisEpsBot}[4]{\RisEpsLarge{#1}{#2}{#3}{#4}{!b}{angle=0}{0}}
\newcommand*{\RisEpsPlace}[5]{\RisEpsLarge{#1}{#2}{#3}{#5}{#4}{angle=0}{0}}

\newcommand*{\RisEpsRot}[4]{\RisEpsLarge{#1}{#2}{#3}{#4}{tbhp}{angle=90}{0}}
\newcommand*{\RisEpsRotTop}[4]{\RisEpsLarge{#1}{#2}{#3}{#4}{!t}{angle=90}{0}}
\newcommand*{\RisEpsRotBot}[4]{\RisEpsLarge{#1}{#2}{#3}{#4}{!b}{angle=90}{0}}
\newcommand*{\RisEpsRotBotPlace}[5]{\RisEpsLarge{#1}{#2}{#3}{#5}{#4}{angle=90}{0}}

\newcommand*{\RisEpsRotClock}[4]{\RisEpsLarge{#1}{#2}{#3}{#4}{tbhp}{angle=-90}{0}}
\newcommand*{\RisEpsRotClockTop}[4]{\RisEpsLarge{#1}{#2}{#3}{#4}{!t}{angle=-90}{0}}
\newcommand*{\RisEpsRotClockBot}[4]{\RisEpsLarge{#1}{#2}{#3}{#4}{!b}{angle=-90}{0}}
\newcommand*{\RisEpsRotClockBotPlace}[5]{\RisEpsLarge{#1}{#2}{#3}{#5}{#4}{angle=-90}{0}}


Finally, the example for this article uses a macro to insert a table into text

\WrapTableBE<\source>
<source lang="tex">\newcommand*{\WrapTableBE}[6]{
\renewcommand{\baselinestretch}{0.75}\small\normalsize
\begin{wraptable}{#1}{#5\textwidth} \sffamily
\begin{center} \vspace*{-#6mm}
\caption{\label{tab:#2}#3} \begin{tabular}{#4} \toprule }
% #1 : l, r #2 : label #3 : caption #4 : cc|cc|rr|ll #5 : 4 #6: 5%    , 

\newcommand*{\WrapTableEN}[2]{
\bottomrule \end{tabular} \end{center} \vspace{-#2pt} \small #1 \end{wraptable}
\renewcommand{\baselinestretch}{1}\small\normalsize}




Chapter 4. Exporting Text to Different Parts of a Book or Other Books



At the end of each chapter, I put a list of problems and a list of questions for the exam. At the end of the book there are these problems with solutions, as well as a complete list of exam questions.

I am also writing a second book in parallel - "Reshebnik", which contains solutions to problems from the textbook. This means that during the compilation of the book, the text is added to the "Reshebnik".

Thus, the same texts should appear in two completely different places. In what follows, for brevity, we will discuss only problems with solutions at the end of the book. I want the statement of each problem to be printed twice, at the end of the chapter and at the end of the book, before the solution.

But I absolutely do not want to have two versions of the same text in different places, because this is the source of an infinite number of errors. This means that the compiler must itself duplicate fragments of text, copying them to different places in different books.

How do I solve this problem. At the end of the preamble, I have the command:

\usepackage{newfile} %   newfile
\newoutputstream{ZO} %     ZO
\openoutputfile{Zadachi.tex}{ZO} %       Zadachi.tex
\newcommand*{\PutNumberZO}{\addtostream{ZO}{$\{$\thechapter.\theenumi$\}$}} %   Zadachi.tex %      .


It opens the Zadachi.tex file and directs a text stream there at compile time. The Zadachi.tex file is empty before starting work, and there is also a Zadachi_Head.tex file that will then be compiled, and which looks, for example, like this:

\chapter{  }
\Epigraf{0.68}{   ,       5 .      12 ,    ?}{"  ", .}
\bigskip
\input{Zadachi}
\endinput
                
\closeoutputstream{ZO}  %   ZO
\include{Zadachi_Head} %   Zadachi_Head.tex 


Here comes the new clipboard package, which has just four commands:

\newclipboard{myclipboard}
- opening the myclipboard.cpy file for writing,

\openclipboard{myclipboard}
- opening the file myclipboard.cpy for reading,

\Copy{item_name}
- writing to the file myclipboard.cpy a fragment with the item_name tag ,

\Paste{item_name}
- reading their myclipboard.cpy file of the fragment labeled item_name .

An important feature of this package is that by storing a piece of text in an external file, it does not forget to compile the piece in the source file. This is how the copying procedure arises. The big drawback of this solution is that we must first open the myclipboard.cpy file for writing, write the task conditions into it, close it, and only then open it for reading. Unfortunately, I did not find an easy way to close and open, so I use a more cumbersome solution: a boolean variable FR (FR = First Run) has been introduced whose value at the first compilation is FR = true, and at subsequent compilation FR = false. And if FR = true then myclipboard.cpy fileopens for writing, and if FR = false then the file myclipboard.cpy is opened for reading.

Unfortunately, before the first and second compilations, you must manually set the value of the FR variable. It’s unpleasant, but it’s okay if you forget to do it. If you always have FR = true or FR = false, then the problem book simply will not have problem conditions, which is quite acceptable when working on chapter texts.

I was too lazy to solve this problem, anyway the text must be compiled at least three times.



Chapter 5. Working with links



5.1 Creating a bibliography

Let's say I'm writing a big review. This means that I pull pieces out of my texts, along with references to literature. At the end, I ask the compiler (BibTex) to revise my previous bibliography scattered across the files Bib_File1.bib, Bib_File2.bib ... using, for example, the command

\bibliography{Bib_File1,Bib_File2,...Bib_FileN}


The link compiler will of course make me the layout of my review, but that isn't enough for me.

When writing books and reviews, it is very useful to have an advanced bibliographic reference sorter. For this, there is the bibMacros package of citizen R. Schlicht. As a result of installing this package, a bunch of commands for working with links will appear in the WinEdt menu in the BibTex section.



In particular, I get the opportunity to create a new file with links from the new review, Bib_FileN + 1.bib, and, at my request, the links can be placed in the correct order (for example, in the order of mentioning in the text, as is customary in physics).



As a reminder, files like bib contain bibliography in the form of entries like this:

@article{Levchenko01_7485,year=2001,
 title={Electronic structure of halogen-substituted methyl radicals: excited states of {CH$_2$Cl and CH$_2$F}},
 author={S{ergey} V. Levchenko and A{nna} I. Krylov},
 journal=JCP,volume=115,pages=7485,numpages=10,
 abstract={Electronically excited states in CH2Cl and CH2F radicals are...}}




5.2 Serpent Gorynych - GOST

Further, the English-speaking comrades have no problems, in my opinion. And we, Russian-speaking, have a big headache. It is called GOST.

The Russian GOST was, undoubtedly, a very highly effective saboteur of some absolutely hostile country to Russia. Here is an example of his work







Fig. 4. Serpent Gorynych - GOST (2008)



As you can see, a Russian-speaking author must write surnames twice, dashingly rearrange initials and surnames and use five different styles of design depending on the number of authors. Practice rearranging the initials and surname, for example, for Messrs. H. Ford III and WS Stoner Jr.



And these are just books. In the articles, the saboteur introduced various oblique and even double sticks - to make it look like no one else in the world has.



In a dissertation, for example, adherence to standards is mandatory. If anything, many job seekers think so. In my time, in 2008, a good person, Polyakov, wrote a package for formatting according to GOST, and I used it to format the bibliography. I'm a fine fellow, but also a black sheep at the same time, because applicants massively ignored this GOST. But everything in the country has only gotten tougher since then, so I don't know how it is now.



And now I have finished the book, and links in it must also be formatted according to GOST. But, as I understand it, the GOST standards in the dissertation and in the book are different, in the book it is less ugly. We go to the Internet, download the Kotelnikov gost package, insert the line into the preamble

\bibliographystyle{gost2008}


after which we format the list of references. The deed is done, all GOSTs are observed.

But even Kotelnikov is sometimes wrong. So, there are minor bugs in his package. (**)

For example, let's say you want to type "Vol. 115". It is a good practice not to have a line break between the "Vol." and "115". And Kotelnikov's package sometimes admits this gap, see fig. 5.





Fig. 5. Poorly formatted record



5.3 Refinement with a file

So, we need to revise it with a file ... (Moreover, not only in this place. The author's index with a mixture of English and Russian names too.) During the compilation of bib files, a file P_bibs.bbl ​​is created containing records type

\bibitem{Levchenko01_7485}
\selectlanguageifdefined{english}
\BibEmph{Levchenko~S.~V., Krylov~A.~I.} Electronic structure of
 halogen-substituted methyl radicals: excited states of {CH$_2$Cl and
 CH$_2$F}~// \BibEmph{J. Chem. Phys.} \BibDash
\newblock 2001. \BibDash
\newblock Vol. 115. \BibDash
\newblock P.~7485.


We find all the wrongs and fix them by hand. In this example, instead of "Vol. 115" we make "Vol. ~ 115". We hide this corrected file in a secluded place. Before the last, final compilation, replace the current P_bibs.bbl ​​file with the corrected one, and everything will turn out well.



Chapter 6. A Minimal Working Example



6.1 List of Files



Here is a minimal book template where you can find the

ideas listed above . The main directory should contain files:

  1. P_main.tex % main in the project
  2. P_preamble.tex % preamble
  3. Ch1.tex % part 1
  4. Ch2.tex % part 2
  5. Figs \ P_ABC.eps % Put your picture P_ABC.eps into the Figs subdirectory.
  6. Zadachi.tex % empty before starting work
  7. Zadachi_Head.tex % title of the part with problems and solutions.




6.2 Small book files, compileable

Hidden text

%  P_main.tex  %   
\documentclass[10pt,twoside,openany]{book}
\usepackage{etoolbox}   % this package introduces operations: \newbool,...

\newbool{For_Internet}
\booltrue{For_Internet}    % %    
%\boolfalse{For_Internet}  %  -  

\newbool{FR} %FR= First Run
%\booltrue{FR}  %  --  make  FR = true
\boolfalse{FR}  %  --  make  FR = false

\input{P_Preamble}       %  
\includeonly{             %     
P_Ch1,        %%%
P_Ch2,        %%%
Zadachi_Head  %%%
}
\begin{document}         %  
\tableofcontents         % 

\ifbool{FR}{\newclipboard{myclipboard}}{}
                          %   
\include{P_Ch1}          %%%
\include{P_Ch2}          %%%

\closeoutputstream{ZO}  %     Zadachi.tex
\ifbool{FR}{}{\openclipboard{myclipboard}}

\include{Zadachi_Head} %      
%\bibliography{P_Bibs}  %   ,   

\end{document}         %  
\endinput              %  ,   
%+++++++++++++++++

%  P_preamble.tex  % 
\usepackage[warn]{mathtext} %(  inputenc, fontenc, babel)
%    ,  
%----   -- 
\usepackage[T2A]{fontenc}
\usepackage[cp1251]{inputenc}
\usepackage[english,russian]{babel}   % load Babel setup for English
                                      % and Russian languages;
                                      % the latter is the default.
%   russian  ,     russian.

%--  
\textheight 187mm
\textwidth 130mm
\headheight13.6pt
\special{papersize=170mm,240mm}
\oddsidemargin -5.4mm
\evensidemargin -5.4mm
\topmargin -5.4mm

%---   
\clubpenalty=400
\widowpenalty=400
\tolerance=500  %max=10000, default=200 (    ).
\looseness=-1 %(     )
\hfuzz=2.5pt %       2.5

%---  
\usepackage{amssymb,amsmath} %   
\usepackage{xspace}
\usepackage{enumerate} % 
\usepackage{booktabs}
\usepackage[dotinlabels]{titletoc}

%--  
\usepackage{graphicx}  %    
%\usepackage[dvips]{color} %   !
\graphicspath{{figs/}} %       *.eps,
\usepackage[usenames,dvipsnames]{xcolor,colortbl}

%---    ,       
\definecolor{lightcyan}{rgb}{0.88,1,1} % : ( 0.88, 1, 1)
\ifbool{For_Internet}{\newcolumntype{g}{>{\columncolor{lightcyan}}c}}%
{\newcolumntype{g}{>{\columncolor{light-gray}}c}}
\newcommand*{\red}[1]{\textcolor[rgb]{1.00,0.00,0.00}{#1}}
\newcommand*{\blue}[1]{\textcolor[rgb]{0.00,0.00,1.00}{#1}}

\ifbool{For_Internet}%
{\renewcommand{\thetable}{\red{{\it\arabic{chapter}.\arabic{table}\,}\normalfont}}}%
{\renewcommand{\thetable}{{\it\arabic{chapter}.\arabic{table}\,}\normalfont}}

\ifbool{For_Internet}%
{\renewcommand{\thefigure}{{\blue{\bfseries{\arabic{chapter}.\arabic{figure}}\normalfont}}}}%
{\renewcommand{\thefigure}{{\bfseries{\arabic{chapter}.\arabic{figure}}\normalfont}}}

%      
 \ifbool{For_Internet}{
 \titlecontents{chapter}[1.8em] % distance to page margin
   {\vspace{3mm} \bfseries\color{blue}} % \sffamily
   {\contentslabel[\thecontentslabel. ]{1.5em}} % distance between 1. and Title of chapter
   {\hspace*{-2.3em}}{\color{blue}
   {\titlerule*[1pc]{}\contentspage}\color{blue}}[\vspace{0.5mm}]
 }{}

\definecolor{light-gray}{gray}{0.95}
\ifbool{For_Internet}{\newcommand*{\CR}{\rowcolor{lightcyan}}}%
{\newcommand*{\CR}{\rowcolor{light-gray}}}

%----     \label{fig:name} \fref{fig:name}
\usepackage[vario]{fancyref} % plain is also possible

\renewcommand*{\fancyrefdefaultspacing}{\fancyreftightspacing}

\frefformat{vario}{\fancyreffiglabelprefix}{\bfseries{#1}\normalfont }
\frefformat{vario}{\fancyreftablabelprefix}{\textit{#1}\normalfont}
\frefformat{vario}{\fancyrefenumlabelprefix}{\textrm{#1}\normalfont}
%   ,   fancyref    .

%---  
\newcommand*{\mb}[1]{\mbox{\boldmath$#1$}}  %  . 

\newcommand*{\BE}{\begin{equation}}        %
\newcommand*{\EN}{\end{equation}}          %

\newcommand*{\BEA}{\begin{subequations} \begin{eqnarray}} %
\newcommand*{\ENA}{\end{eqnarray} \end{subequations}}   %

\newcommand*{\hs}{\hspace*{\parindent}}    %
\newcommand*{\nn}{\nonumber}        %

\newcommand*{\1}{$_1$}
\newcommand*{\2}{$_2$}
\newcommand*{\3}{$_3$}
\newcommand*{\4}{$_4$}
\newcommand*{\5}{$_5$}
\newcommand*{\6}{$_6$}
\newcommand*{\7}{$_7$}
\newcommand*{\8}{$_8$}
\newcommand*{\9}{$_9$}
%
\newcommand*{\T}[1]{\text{#1}}
%
\newcommand*{\vep}[3]{$(#1 \pm #2) \times \! 10 ^{#3} $\xspace} % (v+-e)*10^n
%
\newcommand*{\ic}{$^{-1}$\xspace}                 % inverse centimeters

%----       
\renewcommand{\le}{\leqslant}
\renewcommand{\leq}{\leqslant}
\renewcommand{\ge}{\geqslant}
\renewcommand{\geq}{\geqslant}

%----   
\newcommand*{\TableBE}[5]{
\begin{table}[#1] %\captionabove
\vspace*{-#5mm}
\centering \sffamily \caption{\label{tab:#2}#3} \begin{tabular}{#4} \toprule }

\newcommand*{\TableEN}[3]{
\bottomrule \end{tabular}
\vspace{-#2mm}  \small \begin{flushleft}  #1 \end{flushleft}
\vspace{-#3mm}
\end{table}}

%----    
%  
\newcommand*{\WrapTableBE}[6]{
\renewcommand{\baselinestretch}{0.75}\small\normalsize
\begin{wraptable}{#1}{#5\textwidth} \sffamily
\begin{center} \vspace*{-#6mm}
\caption{\label{tab:#2}#3} \begin{tabular}{#4} \toprule }
% #1 : l, r   #2 : label   #3 : caption  #4 : cc|cc|rr|ll  #5 : 40mm

%    , 
\newcommand*{\WrapTableEN}[2]{
\bottomrule \end{tabular} \end{center} \vspace{-#2pt} \small #1  \end{wraptable}
\renewcommand{\baselinestretch}{1}\small\normalsize}

%----    
\usepackage{wrapfig} %   RisEpsRight

\newcommand*{\EpsWrapD}[7]{%
\begin{wrapfigure}[#5]{#3}{#2 \textwidth} %
\begin{center} \sffamily
\includegraphics*[width= #2 \textwidth ]{#1}
\vspace{-#7mm}
\caption{\label{fig:#1}#4}
\vspace{-#6pt}
\end{center}
\end{wrapfigure}}

%----    
\usepackage{clipboard} % It is used to |copy and \HL\Paste the texts with tasks
\usepackage{newfile}
\newoutputstream{ZO}
\openoutputfile{Zadachi.tex}{ZO}
\newcommand*{\itemZO}[2]{\item  \label{enum:#1}%
\Copy{#1}{\emph{\ifbool{For_Internet}{\blue{ #2 }}{#2}}}%
\addtostream{ZO}{$\{$\thechapter.\theenumi $\}$}}

\endinput

%+++++++++++++++++
%  \Ch1.tex  %  1
\chapter{\label{ch:Chast1}  }
\section{ }
\hs
         (, )  ,        .
       ,       
        .
      wrapfig  floatflt,   .
      ,   .

          
      ,
        ,
  --     TikZ.
%    ,  .      .
          ,   pdf-
  tex$\to$dvi$\to$ps$\to$pdf   
 ,    tex$\to$dvi$\to$pdf.

\section{  }
\hs
    ,     .
   ,       ,     .

          --      .
              .
\BEA
   \sum_{\varkappa=0,...}(1/2)^{\varkappa} \leq {\mb 2}, & \T{   text, $e^x$, \vep{2}{1}{3}   },\\
   \sum\nolimits_{\phi=0,...}(1/2)^{\phi} \le {\mb 2},   & {\text    text, \tg(x) }.
\ENA

\section{   \thechapter}
\begin{enumerate}[$\{$\thechapter.1$\}$]
\begin{writeverbatim}{ZO}
\section{    ~\ref{ch:Chast1}}
\end{writeverbatim}
%---------------------
\itemZO{Zadacha11}{,   ,  $f= \int_0^{\infty} \cos(x/a) \; dx =0$.}
\begin{writeverbatim}{ZO}
\Paste{Zadacha11}\smallskip\\
\hs
   .
     ,  $f = \lim_{R \to \infty} \sin(R/a) = ??$,   .
      -  ,  :
\BE \nn
f = \int_0^{\infty} e^{-bx}\; \cos(x/a) \; dx = \frac{b}{b^2+1/a^2}.
\EN
        .
   ,   ,   $b=0$.
    $f = 0$,    .

\end{writeverbatim}
\end{enumerate}

%+++++++++++++++++
%  \Ch2.tex  %  2
\chapter{\label{ch:Chast2}    }
\section{  ?}
\hs
    ,         \emph{},
   Yo.
          !
      \emph{}!

\section{ }
\hs
             ‘...’  “...”.
       («...»)   („...“) ,   «»  «» .

\WrapTableBE{r}{C2_parties}{   }{g llll}{0.3}{8}
\CR   & I  & II  & III  & IV   \\
\midrule
  & 0 & 0 & 1 & 1  \\
  & 1 & 1 & 0 & 1  \\
  & 0 & 1 & 1 & 0  \\
\WrapTableEN{I, II, III, IV --  , 0  1 --  (, )}{5} %
%
   «»   «» («  ,  „“»).

     «»    \verb|\glqq|   \verb|\grqq|,
  «» --– \verb|\flqq|   \verb|\frqq|.
       babel.

      .
   , «»   ,    -     .

\section{   \thechapter}
\begin{enumerate}[$\{$\thechapter.1$\}$]
\begin{writeverbatim}{ZO}
\section{    ~\ref{ch:Chast2}}
\end{writeverbatim}
%---------------------
\itemZO{Zadacha21}{ .~\fref{tab:C2_parties}        .
          ()    , $0 \le$$\le 1$.
              ,           ? }
\begin{writeverbatim}{ZO}
\Paste{Zadacha21}\hs

\EpsWrapD{P_ABC}{0.28}{r}{ }{8}{0}{6}

   .
      ,     $a+b \ge c$, 
($a,b,c$) --     , . . \fref{fig:P_ABC}.

       --     ,     .
       1.          1,      ,    .
      .

\end{writeverbatim}
\end{enumerate}
\endinput
%  (TikZ)   :
\tikzsetnextfilename{P_ABC}
\begin{tikzpicture}
\coordinate(a) at (1,0);
\coordinate(b) at (-1.3,0);
\coordinate(c) at (0,1);
\draw[very thick] (a) --node[below]{$a$} (b)--node[above left]{$b$} (c)--node[above right]{$c$} (a);
\shade[ball color=blue] (a) circle(0.3) node[below=3mm]{};
\shade[ball color=red]  (b) circle(0.4) node[below=4mm]{};
\shade[ball color=green](c) circle(0.5) node[above=5mm]{};
\end{tikzpicture}

%+++++++++++++++++
%  Figs\P_ABC.eps  % ,  - 

%+++++++++++++++++
%  Zadachi.tex    

%+++++++++++++++++
%  Zadachi_Head.tex %      
\chapter{ }
\input{Zadachi}
\endinput





6.3 The result of compiling these files











Notes

(*) I think the best Russian-language textbook on Latech is the book by Chebotaev and Kotelnikov "LaTeX in Russian", see, for example, here: studlab.com/pdf/book/LaTeX-po-russki.pdf . As far as I know, the copyright for it has already expired, and now nothing prevents readers from downloading the free electronic version.



(**) I informed I. Kotelnikov about this, he promised to fix it.



(Continuation may or may not be.)



All Articles