Série: RISC V Hardware
latex
159 lignes
· Mis à jour 2026-07-04
style.tex
RISC_V_Hardware/latex/common/style.tex
% ============================================================
% 共用樣式檔 style.tex
% 計算機組織與結構 / RISC-V / Verilog 教材
% 編譯方式: xelatex (TeX Live 2024)
% ============================================================
\usepackage[a4paper,top=2.5cm,bottom=2.5cm,left=2.6cm,right=2.6cm,headheight=14pt]{geometry}
% ---------- 中文字型 ----------
\usepackage{fontspec}
\usepackage[slantfont,boldfont]{xeCJK}
\setCJKmainfont[BoldFont={Heiti TC}]{Songti TC}
\setCJKsansfont{Heiti TC}
\setCJKmonofont{Heiti TC}
\setmainfont{Times New Roman}
\setsansfont{Helvetica Neue}
\setmonofont[Scale=0.88]{Menlo}
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt
% ---------- 常用套件 ----------
\usepackage{amsmath,amssymb,amsthm}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{array}
\usepackage{enumitem}
\usepackage{caption}
\usepackage{float}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning,shapes.geometric,calc,fit,backgrounds,decorations.pathreplacing,matrix,chains}
\usepackage{listings}
\usepackage{hyperref}
\usepackage{bytefield}
% ---------- 色彩定義 ----------
\definecolor{primary}{RGB}{0,66,120}
\definecolor{secondary}{RGB}{0,122,160}
\definecolor{accent}{RGB}{190,70,20}
\definecolor{lightbg}{RGB}{242,246,250}
\definecolor{codebg}{RGB}{248,248,244}
\definecolor{codekw}{RGB}{0,80,160}
\definecolor{codestr}{RGB}{160,60,20}
\definecolor{codecmt}{RGB}{90,130,90}
% ---------- 超連結 ----------
\hypersetup{
colorlinks=true,
linkcolor=primary,
urlcolor=secondary,
citecolor=secondary,
bookmarksnumbered=true,
pdfstartview=FitH
}
% ---------- 章節標題樣式 ----------
\titleformat{\section}
{\Large\bfseries\sffamily\color{primary}}
{\thesection}{0.8em}{}[{\color{primary}\titlerule[1.2pt]}]
\titleformat{\subsection}
{\large\bfseries\sffamily\color{secondary}}
{\thesubsection}{0.8em}{}
\titleformat{\subsubsection}
{\normalsize\bfseries\sffamily\color{secondary!80!black}}
{\thesubsubsection}{0.8em}{}
% ---------- 頁首頁尾 ----------
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\small\sffamily\color{primary}\coursetitle}
\fancyhead[R]{\small\sffamily\color{primary}\chaptertitle}
\fancyfoot[C]{\small\thepage}
\renewcommand{\headrulewidth}{0.6pt}
\renewcommand{\headrule}{\color{primary}\hrule width\headwidth height\headrulewidth}
% ---------- 資訊框 ----------
\newtcolorbox{keypoint}[1][重點觀念]{
breakable, enhanced,
colback=lightbg, colframe=primary,
fonttitle=\bfseries\sffamily, title=#1,
boxrule=0.8pt, arc=2pt, left=6pt, right=6pt, top=4pt, bottom=4pt
}
\newtcolorbox{examplebox}[1][範例]{
breakable, enhanced,
colback=white, colframe=secondary,
fonttitle=\bfseries\sffamily, title=#1,
boxrule=0.8pt, arc=2pt, left=6pt, right=6pt, top=4pt, bottom=4pt
}
\newtcolorbox{warningbox}[1][注意]{
breakable, enhanced,
colback=accent!5!white, colframe=accent,
fonttitle=\bfseries\sffamily, title=#1,
boxrule=0.8pt, arc=2pt, left=6pt, right=6pt, top=4pt, bottom=4pt
}
% ---------- 程式碼樣式 ----------
\lstdefinelanguage{RISCVasm}{
morekeywords={add,sub,and,or,xor,sll,srl,sra,slt,sltu,addi,andi,ori,xori,
slli,srli,srai,slti,sltiu,lb,lh,lw,lbu,lhu,sb,sh,sw,beq,bne,blt,bge,
bltu,bgeu,jal,jalr,lui,auipc,ecall,ebreak,fence,csrrw,csrrs,csrrc,
csrrwi,csrrsi,csrrci,mul,mulh,mulhsu,mulhu,div,divu,rem,remu,
li,la,mv,nop,ret,call,j,jr,beqz,bnez,not,neg,seqz,snez},
sensitive=true,
morecomment=[l]{\#},
morestring=[b]",
}
\lstset{
basicstyle=\ttfamily\small,
keywordstyle=\color{codekw}\bfseries,
stringstyle=\color{codestr},
commentstyle=\color{codecmt}\itshape,
backgroundcolor=\color{codebg},
frame=single,
rulecolor=\color{black!25},
numbers=left,
numberstyle=\tiny\color{black!45},
numbersep=6pt,
breaklines=true,
showstringspaces=false,
tabsize=4,
captionpos=b,
xleftmargin=1.6em,
framexleftmargin=1.2em
}
% ---------- 定理環境 ----------
\theoremstyle{definition}
\newtheorem{definition}{定義}[section]
\newtheorem{example}{例}[section]
% ---------- 其他 ----------
\setlength{\parskip}{0.45em}
\setlength{\parindent}{2em}
\renewcommand{\arraystretch}{1.25}
\captionsetup{font=small,labelfont={bf,sf},labelsep=quad}
\renewcommand{\figurename}{圖}
\renewcommand{\tablename}{表}
\renewcommand{\lstlistingname}{程式}
\renewcommand{\contentsname}{目錄}
\renewcommand{\refname}{參考資料}
\renewcommand{\abstractname}{摘要}
% ---------- 章節封面標題指令 ----------
\newcommand{\chapterheader}[3]{%
\begin{center}
{\color{primary}\rule{\textwidth}{2pt}}\\[10pt]
{\small\sffamily\color{secondary}\coursetitle\ \textperiodcentered\ #1}\\[6pt]
{\huge\bfseries\sffamily\color{primary}#2}\\[8pt]
{\large\sffamily\color{black!60}#3}\\[8pt]
{\color{primary}\rule{\textwidth}{2pt}}
\end{center}
\vspace{1em}
}
Articles liés
RISC V Hardware
bash
Mis à jour 2026-07-04
build.sh
build.sh — bash source code from the RISC V Hardware learning materials (RISC_V_Hardware/build.sh).
Lire l'article →
RISC V Hardware
verilog
Mis à jour 2026-07-04
alu.v
alu.v — verilog source code from the RISC V Hardware learning materials (RISC_V_Hardware/verilog/rtl/alu.v).
Lire l'article →
RISC V Hardware
verilog
Mis à jour 2026-07-04
branch_unit.v
branch_unit.v — verilog source code from the RISC V Hardware learning materials (RISC_V_Hardware/verilog/rtl/branch_unit.v).
Lire l'article →
RISC V Hardware
verilog
Mis à jour 2026-07-04
control.v
control.v — verilog source code from the RISC V Hardware learning materials (RISC_V_Hardware/verilog/rtl/control.v).
Lire l'article →
RISC V Hardware
verilog
Mis à jour 2026-07-04
dmem.v
dmem.v — verilog source code from the RISC V Hardware learning materials (RISC_V_Hardware/verilog/rtl/dmem.v).
Lire l'article →
RISC V Hardware
verilog
Mis à jour 2026-07-04
imem.v
imem.v — verilog source code from the RISC V Hardware learning materials (RISC_V_Hardware/verilog/rtl/imem.v).
Lire l'article →