我仍在制作一本类似风格的书https://fac.ksu.edu.sa/sites/default/files/numerical_analysis_9th.pdf。这主要包括在左边距标注章节编号以及定理和图形标签。
目前我正在使用 marginnote 包来尝试实现这一点,但是,当字体很大时,比如使用 \huge 命令或 \fontsize,边注与文本垂直不对齐。我想知道是否有人可以帮助我解决这个问题,或者我是否应该使用 marginnotes 来做到这一点(也许有更好的方法)。
无论如何,这是我的 MWE 类文件和相应的 tex 文件。谢谢。
注释.cls
% notes.cls
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{notes}
\LoadClass{article}
\usepackage{geometry}
\usepackage{marginnote}
\usepackage{xcolor}
\usepackage{layout}
\usepackage{anyfontsize}
\usepackage{mdframed}
\usepackage{mathptmx}
\geometry{
letterpaper,
left=2in,
right=1in,
marginparwidth=1.5in,
marginparsep=.25in
}
\setlength\parindent{0pt}
\reversemarginpar
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% setup counters for custom sections
\newcounter{ChpCounter}
\newcounter{SecCounter}[ChpCounter]
\newcounter{SubCounter}[SecCounter]
\newcounter{SubSubCounter}[SubCounter]
% Setup counters for side margins
\newcounter{TheoremCounter}[SecCounter]
\newcounter{DefinitionCounter}[SecCounter]
\newcounter{ExampleCounter}[SecCounter]
\newcounter{FigureCounter}[SecCounter]
\newcounter{TableCounter}[SecCounter]
% Insert side margin notes
% Use \side{param}
% param:
% Theorem
% Definition
% Example
% Figure
% Table
\newcommand{\side}[1]{{\marginnote{
\color[HTML]{156EC7} \large \textbf{#1 \theSecCounter.\the\value{#1Counter}}}} \stepcounter{#1Counter}}
% Section bar length
\newlength{\mylength}
\setlength{\mylength}{\linewidth}
\addtolength{\mylength}{\marginparwidth}
% \addtolength{\mylength}{\marginparsep}
\newcommand{\zchp}[1]{
\stepcounter{ChpCounter}
\marginnote{{\textbf {\fontsize{40}{48}\selectfont \theChpCounter}}}
{\textbf{\fontsize{40}{48}\selectfont #1}}
\vspace{100px}
\newline
}
\newcommand{\zsec}[1]{
\stepcounter{SecCounter}
\stepcounter{TheoremCounter}
\stepcounter{DefinitionCounter}
\stepcounter{ExampleCounter}
\stepcounter{FigureCounter}
\stepcounter{TableCounter}
\noindent{\color[HTML]{156EC7}\makebox[\linewidth][r]{\rule{\mylength}{3pt}}}
\marginnote{\textbf{{\fontsize{30}{34}\selectfont \theChpCounter.\theSecCounter}}}
{\fontsize{30}{34}\selectfont \textbf{#1}}
}
\newcommand{\zsub}[1]{
\stepcounter{SubCounter}
\marginnote{\theChpCounter.\theSecCounter.\theSubCounter}
#1
}
\newcommand{\zsubsub}[1]{
\stepcounter{SubSubCounter}
\marginnote{\theChpCounter.\theSecCounter.\theSubCounter.\theSubSubCounter}
#1
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
注释.tex
% notes.tex
\documentclass{notes}
\usepackage{showframe}
\usepackage{tikz}
\usepackage{hyperref}
\usepackage{contour}
\usepackage{ifthen}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\begin{document}
\zchp{Chapter}
\zsec{Section}
\end{document}