如何製作自己的 LaTeX 模板?

如何製作自己的 LaTeX 模板?

好吧,我知道我的問題很本地化,但是,我已經苦苦掙扎了很長時間並且找不到答案,所以我決定將其發佈在這裡。

我必須用LaTeX重寫一本書(用Word寫的),而不改變結構和內容。

本書分為兩部分;第 1 部分有 2 章,第 2 部分有 3 章。章節依字母編號,如Chapter A, Chapter B,... ,每章的定理依其章節編號,如Theorem A1, Theorem B7,...

我在網路上搜尋過書籍模板,但沒有找到完全適合這種風格的書籍的模板。每次我嘗試時,我都會遇到編號定理、索引和內容的麻煩...:|

你能幫我編寫適當的 LaTeX 程式碼嗎?請不要告訴我應該改變這本書的行為方式,因為作者想保留它,而我只是一個編輯。

感謝您閱讀我的問題!

更新: 這是我拍的圖: 在此輸入影像描述

對於定理,我是手工編號的,如下代碼:

   \indent \textbf{Định lý A1.}
    (Thales thuận dạng hình học)\emph{Nếu ba đường thẳng đôi một song song $a, b, c$ cùng bị hai đường thẳng $\Delta, \Delta'$ tương ứng cắt tại $A, B, C; A’, B’, C’$ thì $\dfrac{AB}{BC}=\dfrac{A'B'}{B'C'}$. }  

答案1

這是一個非常基本的方法,使用 -classbookamsmath-commands:

\documentclass{book}

\usepackage{mathtools} % loads the ams-packages and provides some fixes
\usepackage{lipsum} % for dummy text only

\renewcommand{\thechapter}{\Alph{chapter}} % change chapter numbering to A, B, C, ...
\newtheorem{mytheorem}{Theorem} % define new theorem style

\begin{document}
\tableofcontents

\chapter{Lorem Ipsum}
\lipsum[1]

\begin{mytheorem} %first theorem - this will be "A.1"
\begin{align}
    a^2+b^2=c^2
\end{align}
\end{mytheorem}

\lipsum[2-5]

\chapter{Lorem Ipsum}
\lipsum[6-8]

\begin{mytheorem} %second theorem - this will be B.1
\begin{align}
    1+1=3
\end{align}
\end{mytheorem}

\lipsum[9]

\end{document}

螢幕截圖

編輯

根據您的螢幕截圖,請嘗試以下操作 - 您必須mytheorem從上一個範例中刪除舊的定義,然後新增:

\usepackage{chngcntr} %allows you to reset counters within others

\newcounter{mytheoremcounter} %create a counter for your theorems
\setcounter{mytheoremcounter}{0}%set them to zero. At the begin of every theorem
    %, this gets increased by one, so the first theorem will be '1'
\counterwithin{mytheoremcounter}{chapter} % reset the counter in every chapter

\newenvironment{mytheorem}{%
    \addtocounter{mytheoremcounter}{1}%
    \indent\textbf{Theorem \thechapter\arabic{mytheoremcounter}.}
}{}

然後寫下以下內容:

\begin{mytheorem}
(Lorem Ipsum Dolor Sit Amet) \emph{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
Ut purus elit, vestibu- lum ut, placerat ac, adipiscing vitae, felis. $\Delta$, $\Delta'$ 
Curabitur dictum gravida mauris. $A, B, C; A’, B’, C’$ mollis ac, nulla
$\dfrac{AB}{BC}=\dfrac{A'B'}{B'C'}$. }  
\end{mytheorem}

這會產生:

在此輸入影像描述

編輯2

改進後的介面得到相同的結果:

\newenvironment{mytheorem}[1]{
    \addtocounter{mytheoremcounter}{1}
    \indent\textbf{Theorem \thechapter\arabic{mytheoremcounter}.} (#1) \em
}{}

像這樣使用它:

\begin{mytheorem}{The title}
    The theorem
\end{mytheorem}

有了 ,\em您就不需要\emph{...}每次都寫 。

相關內容