%! TEX program = xelatex
\documentclass[English,French,puretext]{simplivre}

\CreateTheorem{definition}<highest>
\CreateTheorem{theorem}<highest>

\linenumbers % Enable line numbers

%%================================
%% Import toolkit
%%================================
\usepackage{ProjLib}
\usepackage{longtable}  % breakable tables
\usepackage{hologo}     % more TeX logo

%%================================
%% For typestting code
%%================================
\usepackage{listings}
\definecolor{maintheme}{RGB}{70,130,180}
\definecolor{forestgreen}{RGB}{21,122,81}
\definecolor{lightergray}{gray}{0.99}
\lstset{language=[LaTeX]TeX,
    keywordstyle=\color{maintheme},
    basicstyle=\ttfamily,
    commentstyle=\color{forestgreen}\ttfamily,
    stringstyle=\rmfamily,
    showstringspaces=false,
    breaklines=true,
    frame=lines,
    backgroundcolor=\color{lightergray},
    flexiblecolumns=true,
    escapeinside={(*}{*)},
    % numbers=left,
    numberstyle=\scriptsize, stepnumber=1, numbersep=5pt,
    firstnumber=last,
} 
\providecommand{\meta}[1]{$\langle${\normalfont\itshape#1}$\rangle$}
\lstset{moretexcs=%
    {linenumbers,nolinenumbers,part,chapter,section,subsection,subsubsection,href,
    color,NameTheorem,CreateTheorem,proofideanameEN,cref,dnf,needgraph,UseLanguage,UseOtherLanguage,AddLanguageSetting,maketitle,address,curraddr,email,keywords,subjclass,thanks,dedicatory,PLdate,ProjLib,parttext,qedhere
    }
}
\lstnewenvironment{code}% 
{\LocallyStopLineNumbers%
\setkeys{lst}{columns=fullflexible,keepspaces=true}%
}
{\ResumeLineNumbers}

%%================================
%% tip
%%================================
\usepackage[many]{tcolorbox}
\newenvironment{tip}[1][Tip]{%
    \LocallyStopLineNumbers%
    \begin{tcolorbox}[breakable,
        enhanced,
        width = \textwidth,
        colback = paper, colbacktitle = paper,
        colframe = gray!50, boxrule=0.2mm,
        coltitle = black,
        fonttitle = \sffamily,
        attach boxed title to top left = {yshift=-\tcboxedtitleheight/2, xshift=.5cm},
        boxed title style = {boxrule=0pt, colframe=paper},
        before skip = 0.3cm,
        after skip = 0.3cm,
        top = 3mm,
        bottom = 3mm,
        title={\scshape\sffamily #1}]%
}{\end{tcolorbox}\ResumeLineNumbers}

%%================================
%% 名称
%%================================
\providecommand{\minimalist}{\textsf{minimalist}}
\providecommand{\minimart}{\textsf{minimart}}
\providecommand{\minimbook}{\textsf{minimbook}}
\providecommand{\einfart}{\textsf{einfart}}
\providecommand{\simplivre}{\textsf{simplivre}}

\usetikzlibrary{calc}

\usepackage{blindtext}

%%================================
%% Main text
%%================================
\begin{document}

% \title{\simplivre{}, write your books in a simple and clear way}
% \author{Jinwen XU}
% \thanks{Corresponding to: \texttt{\simplivre{} 2021/05/23}}
% \date{May 2021, Beijing}

% \maketitle

\frontmatter

\begin{titlepage} % Suppresses displaying the page number on the title page and the subsequent page counts as page 1
\begin{tikzpicture}[overlay,remember picture]
    \fill [cyan!90!black] ($(current page.south west)+(0,7)$) rectangle ($(current page.north west)+(21,-7)$);
    \fill [yellow] (current page.south west) rectangle ($(current page.north west)+(3,0)$);
    \node[text width=10cm] at ($(current page.north west)+(8.5,-6)$) {\huge\ProjLib};
    \node[text width=6cm,text height=3.5cm,scale=2.5] at ($(current page.north west)+(11,-9)$) {\textcolor{white}{\sffamily\simplivre{}\\[5pt]\footnotesize\textsc{Write your books in \\a simple and clear way}\\[10pt]\tiny Corresponding to: \texttt{\simplivre{} 2021/07/05}}};
    \node at ($(current page.south)+(1.5,3)$) {\fontsize{16pt}{0pt}\selectfont\textcolor{gray}{\scshape Jinwen XU}};
    \node at ($(current page.south)+(1.5,2)$) {\fontsize{12pt}{0pt}\selectfont\textcolor{gray}{July 2021, Beijing}};
\end{tikzpicture}%
\end{titlepage}%
\cleardoublepage%

\chapter*{Preface}

\simplivre{} is part of the \minimalist{} class series. Its name is taken from French words ``simple'' and ``livre'' (for ``book''). The entire collection includes \minimart{} and \einfart{} for typesetting articles, and \minimbook{} and \simplivre{} for typesetting books. My original intention in designing them was to write drafts and notes that look simple yet not shabby.

\simplivre{} has multi-language support, including Chinese (simplified and traditional), English, French, German, Italian, Japanese, Portuguese (European and Brazilian), Russian and Spanish. These languages can be switched seamlessly in a single document. Due to the usage of custom fonts, \einfart{} requires \hologo{XeLaTeX} or \hologo{LuaLaTeX} to compile.

This documentation is typeset using \simplivre{}. You can think of it as a short introduction and demonstration.

\bigskip
\begin{tip}
    Multi-language support, theorem-like environments, draft marks and some other features are provided by the \ProjLib{} toolkit. Here we only briefly discuss how to use it with this document class. For more detailed information, you can refer to the documentation of \ProjLib{}.
\end{tip}

\tableofcontents

\mainmatter

\part{Instruction}
\parttext{You can add some introduction text here via \lstinline|\\parttext|\meta{text}.}

\chapter{Initialization}

\section{How to load it}

One only needs to put

\begin{code}
  \documentclass{simplivre}
\end{code}

as the first line to use the \simplivre{} class.

\begin{tip}[Attention]
    You need to use either \hologo{XeLaTeX} or \hologo{LuaLaTeX} engine to compile.
\end{tip}

\section{Options}

\simplivre{} offers the following options: 

\begin{itemize}
    \item The language options \texttt{EN} / \texttt{english} / \texttt{English}, \texttt{FR} / \texttt{french} / \texttt{French}, etc.
        \begin{itemize}
            \item For the option names of a specific language, please refer to \meta{language name} in the next section. The first specified language will be used as the default language.
        \end{itemize}
    \item \texttt{draft} or \texttt{fast}
        \begin{itemize}
            \item The option \verb|fast| enables a faster but slightly rougher style, main differences are:
            \begin{itemize}
                \item Use simpler math font configuration; 
                \item Do not use \textsf{hyperref}; 
                \item Enable the fast mode of \ProjLib{} toolkit.
            \end{itemize}
        \end{itemize}
\begin{tip}
    During the draft stage, it is recommended to use the \verb|fast| option to speed up compilation. When in \verb|fast| mode, there will be a watermark ``DRAFT'' to indicate that you are currently in the draft mode.
\end{tip}
    \item \texttt{a4paper} or \texttt{b5paper}
        \begin{itemize}
            \item Optional paper size. The default paper size is 7in $\times$ 10in.
        \end{itemize}
    \clearpage
    \item \texttt{palatino}, \texttt{times}, \texttt{garamond}, \texttt{biolinum} ~$|$~ \texttt{useosf}
        \begin{itemize}
            \item Font options. As the name suggest, font with corresponding name will be loaded. 
            \item The \texttt{useosf} option is used to enable the old-style figures.
        \end{itemize}
    \item \texttt{allowbf}
        \begin{itemize}
            \item Allow boldface. When this option is enabled, the main title, the titles of all levels and the names of theorem-like environments will be bolded.
        \end{itemize}
    \item \texttt{classical}
        \begin{itemize}
            \item Classic mode. When this option is enabled, the style will become more regular: paragraphs are indented, the use of underlines are reduced, heading styles are changed, and the theorem styles will be much closer to common styles.
        \end{itemize}
\begin{tip}
    \texttt{allowbf} + \texttt{classical} is probably a good choice if you prefer traditional style.
\end{tip}
    \item \texttt{useindent}
        \begin{itemize}
            \item Use paragraph indentation instead of inter-paragraph spacing.
        \end{itemize}
    \item \texttt{runin}
        \begin{itemize}
            \item Use the ``runin'' style for \lstinline|\subsubsection|
        \end{itemize}
    \item \texttt{puretext} or \texttt{nothms}
        \begin{itemize}
            \item Pure text mode. Does not load theorem-like environments.
        \end{itemize}
    \item \texttt{nothmnum}
        \begin{itemize}
            \item Theorem-like environments will not be numbered.
        \end{itemize}
\end{itemize}

\bigskip
In addition, the commonly used \texttt{oneside} and \texttt{twoside} options are also available. Two-page layout is used by default.

\chapter{On the default fonts}
By default, \simplivre{} uses Palatino Linotype as the English font, FounderType's YouSong and YouHei GBK as the Chinese fonts, and partially uses Neo Euler as the math font. Among them, Neo Euler can be downloaded at \url{https://github.com/khaledhosny/euler-otf}. The other fonts are not free, you need to purchase and install them on your own. (For the Chinese fonts, visit FounderType's website for detail: \url{https://www.foundertype.com} ).

\begin{tip}[Font demonstration]
    \begin{itemize}
        \item English main font. \textsf{English sans serif font}. \texttt{English typewriter font}.
        \item 中文主要字体，\textsf{中文无衬线字体}
        \item 数学示例:  \( \alpha, \beta, \gamma, \delta, 1,2,3,4, a,b,c,d \), \[\mathrm{li}(x)\coloneqq \int_2^{\infty} \frac{1}{\log t}\,\mathrm{d}t \]
    \end{itemize}
\end{tip}

\bigskip
When the corresponding font is not installed, fonts that comes with TeX Live will be used instead. In this case, the experience might be reduced.


\chapter{Some instructions}

Many of the features described next are provided by the \ProjLib{} toolkit. Only the basic usage is mentioned here. For more details, please refer to its user documentation.

\section{Language configuration}

\simplivre{} has multi-language support, including Chinese (simplified and traditional), English, French, German, Italian, Japanese, Portuguese (European and Brazilian), Russian and Spanish. The language can be selected by the following macros:

\begin{itemize}
    \item \lstinline|\UseLanguage{|\meta{language name}\lstinline|}| is used to specify the language. The corresponding setting of the language will be applied after it. It can be used either in the preamble or in the main body. When no language is specified, ``English'' is selected by default.
    \item \lstinline|\UseOtherLanguage{|\meta{language name}\lstinline|}{|\meta{content}\lstinline|}|, which uses the specified language settings to typeset \meta{content}. Compared with \lstinline|\UseLanguage|, it will not modify the line spacing, so line spacing would remain stable when CJK and Western texts are mixed.
\end{itemize}

\meta{language name} can be (it is not case sensitive, for example, \texttt{French} and \texttt{french} have the same effect):
\begin{itemize}
    \item Simplified Chinese: \texttt{CN}, \texttt{Chinese}, \texttt{SChinese} or \texttt{SimplifiedChinese}
    \item Traditional Chinese: \texttt{TC}, \texttt{TChinese} or \texttt{TraditionalChinese}
    \item English: \texttt{EN} or \texttt{English}
    \item French: \texttt{FR} or \texttt{French}
    \item German: \texttt{DE}, \texttt{German} or \texttt{ngerman}
    \item Italian: \texttt{IT} or \texttt{Italian}
    \item Portuguese: \texttt{PT} or \texttt{Portuguese}
    \item Portuguese (Brazilian): \texttt{BR} or \texttt{Brazilian}
    \item Spanish: \texttt{ES} or \texttt{Spanish}
    \item Japanese: \texttt{JP} or \texttt{Japanese}
    \item Russian: \texttt{RU} or \texttt{Russian}
\end{itemize}

\medskip
In addition, you can also add new settings to selected language:
\begin{itemize}
    \item \lstinline|\AddLanguageSetting{|\meta{settings}\lstinline|}|
    \begin{itemize}
        \item Add \meta{settings} to all supported languages.
    \end{itemize}
    \item \lstinline|\AddLanguageSetting(|\meta{language name}\lstinline|){|\meta{settings}\lstinline|}|
    \begin{itemize}
        \item Add \meta{settings} to the selected language \meta{language name}.
    \end{itemize}
\end{itemize}
For example, \lstinline|\AddLanguageSetting(German){\color{orange}}| can make all German text displayed in orange (of course, one then need to add \lstinline|\AddLanguageSetting{\color{black}}| in order to correct the color of the text in other languages).


\section{Theorems and how to reference them}

Environments such as \texttt{definition} and \texttt{theorem} have been pre-defined and can be used directly.  

More specifically, preset environments include: 
\texttt{assumption}, \texttt{axiom}, \texttt{conjecture}, \texttt{convention}, \texttt{corollary}, \texttt{definition}, \texttt{definition-proposition}, \texttt{definition-theorem}, \texttt{example}, \texttt{exercise}, \texttt{fact}, \texttt{hypothesis}, \texttt{lemma}, \texttt{notation}, \texttt{problem}, \texttt{property}, \texttt{proposition}, \texttt{question}, \texttt{remark}, \texttt{theorem}, and the corresponding unnumbered version with an asterisk \lstinline|*| in the name. The titles will change with the current language. For example, \texttt{theorem} will be displayed as ``Theorem" in English mode and ``Théorème" in French mode.

When referencing a theorem-like environment, it is recommended to use \lstinline|\cref{|\meta{label}\texttt{\}}. In this way, there is no need to explicitly write down the name of the corresponding environment every time.

\begin{tip}[Example]
\begin{code}
  \begin{definition}[Strange things] \label{def: strange} ...
\end{code}

will produce
\begin{definition}[Strange things]\label{def: strange}
    This is the definition of some strange objects. There is approximately an one-line space before and after the theorem environment, and there will be a symbol to mark the end of the environment.
\end{definition}

\lstinline|\cref{def: strange}| will be displayed as: \cref{def: strange}.

After using \lstinline|\UseLanguage{French}|, a theorem will be displayed as:

\UseLanguage{French}
\begin{theorem}[Inutile]\label{thm}
    Un théorème en français.
\end{theorem}

By default, when referenced, the name of the theorem always matches the language of the context in which the theorem is located. For example, the definition above is still displayed in English in the current French mode: \cref{def: strange} and \cref{thm}. If you want the name of the theorem to match the current context when referencing, you can add \texttt{regionalref} to the global options.
\end{tip}

\UseLanguage{English}


\section{Define a new theorem-like environment}

If you need to define a new theorem-like environment, you must first define the name of the environment in the language to use:
\begin{itemize}
    \item \lstinline|\NameTheorem[|\meta{language name}\lstinline|]{|\meta{name of environment}\lstinline|}{|\meta{name string}\lstinline|}|
\end{itemize}
For \meta{language name}, please refer to the section on language configuration. When \meta{language name} is not specified, the name will be set for all supported languages. In addition, environments with or without asterisk share the same name, therefore, \lstinline|\NameTheorem{envname*}{...}| has the same effect as \lstinline|\NameTheorem{envname}{...}| .

\medskip
And then define this environment in one of following five ways:
\begin{itemize}
    \item \lstinline|\CreateTheorem*{|\meta{name of environment}\lstinline|}|
        \begin{itemize}
            \item Define an unnumbered environment \meta{name of environment}
        \end{itemize}
    \item \lstinline|\CreateTheorem{|\meta{name of environment}\lstinline|}|
        \begin{itemize}
            \item Define a numbered environment \meta{name of environment}, numbered in order 1,2,3,\dots
        \end{itemize}
    \item \lstinline|\CreateTheorem{|\meta{name of environment}\lstinline|}[|\meta{numbered like}\lstinline|]|
        \begin{itemize}
            \item Define a numbered environment \meta{name of environment}, which shares the counter \meta{numbered like}
        \end{itemize}
    \item \lstinline|\CreateTheorem{|\meta{name of environment}\lstinline|}<|\meta{numbered within}\lstinline|>|
        \begin{itemize}
            \item Define a numbered environment \meta{name of environment}, numbered within the \\counter \meta{numbered within}
        \end{itemize}
    \item \lstinline|\CreateTheorem{|\meta{name of environment}\lstinline|}(|\meta{existed environment}\lstinline|)|\\
    \lstinline|\CreateTheorem*{|\meta{name of environment}\lstinline|}(|\meta{existed environment}\lstinline|)|
        \begin{itemize}
            \item Identify \meta{name of environment} with \meta{existed environment} or \meta{existed environment}\lstinline|*|.
            \item This method is usually useful in the following two situations:
                \begin{enumerate}
                    \item To use a more concise name. For example, with \lstinline|\CreateTheorem{thm}|\\\lstinline|(theorem)|, one can then use the name \texttt{thm} to write theorem.
                    \item To remove the numbering. For example, one can remove the numbering of the \texttt{remark} environment with \lstinline|\CreateTheorem{remark}(remark*)|.
                \end{enumerate}
        \end{itemize}
\end{itemize}

\begin{tip}
    This macro utilizes the feature of \textsf{amsthm} internally, so the traditional \texttt{theoremstyle} is also applicable to it. One only needs declare the style before the relevant definitions.
\end{tip}

% \def\proofideanameEN{Idea}
\NameTheorem[EN]{proofidea}{Idea}
\CreateTheorem*{proofidea*}
\CreateTheorem{proofidea}<section>

\bigskip
Here is an example. The following code:

\begin{code}
  \NameTheorem[EN]{proofidea}{Idea}
  \CreateTheorem*{proofidea*}
  \CreateTheorem{proofidea}<section>
\end{code}

defines an unnumbered environment \lstinline|proofidea*| and a numbered environment \lstinline|proofidea| (numbered within section) respectively. They can be used in English context. The effect is as follows:

\begin{proofidea*}
    The \lstinline|proofidea*| environment.
\end{proofidea*}

\begin{proofidea}
    The \lstinline|proofidea| environment.
\end{proofidea}

% \clearpage 
\section{Draft mark}

You can use \lstinline|\dnf| to mark the unfinished part. For example:
\begin{itemize}
    \item \lstinline|\dnf| or \lstinline|\dnf<...>|. The effect is: \dnf~ or \dnf<...>. \\The prompt text changes according to the current language. For example, it will be displayed as \UseOtherLanguage{French}{\dnf} in French mode.
\end{itemize}

Similarly, there is \lstinline|\needgraph| : 
\begin{itemize}
    \item \lstinline|\needgraph| or \lstinline|\needgraph<...>|. The effect is: \needgraph or \needgraph<...>The prompt text changes according to the current language. For example, in French mode, it will be displayed as \UseOtherLanguage{French}{\needgraph}
\end{itemize}

% \vspace{-.5\baselineskip}
% \section{On the title, abstract and keywords}

% \simplivre{} has both the features of standard classes and that of the \AmS{} classes.

% Therefore, the title part can either be written in the usual way, in accordance with the standard class \textsf{article}:

% \begin{code}
%   \title{(*\meta{title}*)}
%   \author{(*\meta{author}*)}
%   \date{(*\meta{date}*)}
%   \maketitle
%   \begin{abstract}
%       (*\meta{abstract}*)
%   \end{abstract}
%   \begin{keyword}
%       (*\meta{keywords}*)
%   \end{keyword}
% \end{code}

% \vspace{-.5\baselineskip}
% or written in the way of \AmS{} classes:

% \begin{code}
%   \title{(*\meta{title}*)}
%   \author{(*\meta{author}*)}
%   \address{(*\meta{address}*)}
%   \email{(*\meta{email}*)}
%   \date{(*\meta{date}*)}
%   \keywords{(*\meta{keywords}*)}
%   \subjclass{(*\meta{subjclass}*)}
%   \begin{abstract}
%       (*\meta{abstract}*)
%   \end{abstract}
%   \maketitle
% \end{code}

% \medskip
% The author information can contain multiple groups, written as:

% \begin{code}
%   \author{(*\meta{author 1}*)}
%   \address{(*\meta{address 1}*)}
%   \email{(*\meta{email 1}*)}
%   \author{(*\meta{author 2}*)}
%   \address{(*\meta{address 2}*)}
%   \email{(*\meta{email 2}*)}
%   ...
% \end{code}

% Among them, the mutual order of \lstinline|\address|, \lstinline|\curraddr|, \lstinline|\email| is not important.

\section{On the line numbers}
Line numbers can be turned on and off at any time. \lstinline|\linenumbers| is used to enable the line numbers, and \lstinline|\nolinenumbers| is used to disable them. For the sake of beauty, the title, table of contents, index and some other elements are not numbered.

\section{On the footnotes in the title}
In \lstinline|\section| or \lstinline|\subsection| , if you wish to add footnotes, you can only:
\begin{itemize}
    \item first write \lstinline|\mbox{\protect\footnotemark}|, 
    \item then add \lstinline|\footnotetext{...}| afterwards. 
\end{itemize}
This is a disadvantage brought about by the underline decoration of the title.

\section{On the QED symbols}
Since the font in the theorem-like environments is the same as that of the main text, in order to indicate where the environments end, a hollow QED symbol \simpleqedsymbol{} is placed at the end of the theorem-like environments. However, if your theorem ends with an equation or list (itemize, enumerate, description, etc.), this symbol cannot be automatically placed in the correct position. In this case, you need to manually add a \lstinline|\qedhere| at the end of your equation or the last entry of your list to make the QED symbol appear at the end of the line.


\clearpage
\section{Known issues}

\begin{itemize}[itemsep=.6em]
    \item The font settings are still not perfect.
    \item Since many features are based on the \ProjLib{} toolkit, \simplivre{} inherits all its problems. For details, please refer to the "Known Issues" section of the \ProjLib{} documentation.
    \item The error handling mechanism is incomplete: there is no corresponding error prompt when some problems occur.
    \item There are still many things that can be optimized in the code.
\end{itemize}


\part{Demonstration}

\chapter{Document templates}

\vspace*{-1.5\baselineskip}

\section{The standard way}

If you want to write in the standard way, you can refer to the following example:

\begin{code}
\documentclass{simplivre}
\usepackage{ProjLib} % Load ProjLib toolkit

\UseLanguage{French} % Use French from here

\begin{document}

\title{Le Titre}
\author{Auteur}
\date{\PLdate{2022-04-01}}

\maketitle

\chapter{Un théorème}

%% Theorem-like environments can be used directly
\begin{theorem}\label{thm:abc}
    Ceci est un théorème.
\end{theorem}

Référence du théorème: \cref{thm:abc} 
    % It is recommended to use clever reference

\end{document}
\end{code}

If you wish to switch to the standard class later, just replace the first two lines with:

\begin{code}
\documentclass{article}
\usepackage[a4paper,margin=1in]{geometry}
\usepackage[hidelinks]{hyperref}
\usepackage[palatino]{ProjLib} % Load ProjLib toolkit
\end{code}


\clearpage
\section{The \texorpdfstring{\AmS{}}{AMS} way}

If you intend to switch to the journal template in the future and thus want to use the writing style as in the \AmS{} classes, you can refer to the following example:

\begin{code}
\documentclass{simplivre}
\usepackage{ProjLib} % Load ProjLib toolkit

\UseLanguage{French} % Use French from here

\begin{document}

\title{Le Titre}
\author{Auteur 1}
\address{Adresse 1}
\email{\href{Courriel 1}{Courriel 1}}
\author{Auteur 1}
\address{Adresse 1}
\email{\href{Courriel 2}{Courriel 2}}
\date{\PLdate{2022-04-01}}
\subjclass{*****}
\keywords{...}

\maketitle

\chapter{Première section}

%% Theorem-like environments can be used directly
\begin{theorem}\label{thm:abc}
    Ceci est un théorème.
\end{theorem}

Référence du théorème: \cref{thm:abc} 
    % It is recommended to use clever reference

\end{document}
\end{code}

\vspace{-0.3\baselineskip}
In this way, if you wish to switch to \AmS{} class later, just replace the first two lines with:

\begin{code}
\documentclass{amsart}
\usepackage[a4paper,margin=1in]{geometry}
\usepackage[hidelinks]{hyperref}
\usepackage[palatino]{ProjLib} % Load ProjLib toolkit
\end{code}

\blinddocument

\end{document}
