我使用了此代码,但出现错误:
! \@ 的使用与其定义不符。
我正在尝试制作如下书:
\documentclass[a4paper,14pt,twoside]{tufte-book}
\usepackage{amsthm,amssymb,amsmath}
\usepackage{graphicx ,xcolor ,mdframed}
\usepackage[version=0.96]{pgf}
%\input{mystyle}
\setcounter{secnumdepth}{3}
\usepackage{color}
\def\chpcolor{blue!45}
\def\chpcolortxt{blue!60}
%Section: ---------------------------------------------------------------------------------
\def\@makesectionhead#1{
{ \vspace{20pt}
\parindent 0pt \raggedleft \sectionfont
\colorbox{\chpcolor} { \parbox[c][17pt][c]{90pt}{\color{white} \hfill \thesection }}
\hspace*{5pt}
\vspace{10pt}
\begin{minipage}[c][17pt][c]{\textwidth}
\color{\chpcolortxt} #1
\end{minipage}
}
}
\def\section{\@afterindentfalse \secdef\@section\@ssection}
\def\@section[#1]#2{\ifnum \c@secnumdepth >\m@ne
\refstepcounter{section}
\addcontentsline{toc}{section}{\protect
\numberline{\thesection}#1}\else
\addcontentsline{toc}{section}{#1}\fi
\sectionmark{#1}
\if@twocolumn\@topnewpage[\@makesectionhead{#2}]
\else \@makesectionhead{#2}\@afterheading \fi}
\def\@ssection#1{\if@twocolumn \@topnewpage[\@makesectionhead{#1}]
\else \@makesectionhead{#1}\@afterheading\fi}
\begin{document}
\chapter{chapter}
This is test.
\section{section}
This is test.
\end{document}
答案1
在从输入中删除所有不可见字符后,仍然存在一些问题。例如,为了使用@
名称中带有 的命令,您必须用\makeatletter
和包围代码\makeatother
。
我已尝试纠正代码中的小问题;这是一个仅包含所需软件包的版本。我尝试猜测 的含义\sectionfont
。
\documentclass[a4paper,twoside]{tufte-book}
\usepackage{xcolor}
\def\chpcolor{blue!45}
\def\chpcolortxt{blue!60}
\def\sectionfont{\sffamily\LARGE}
\setcounter{secnumdepth}{2}
\makeatletter
%Section:
\def\@sectionstrut{\vrule\@width\z@\@height12.5\p@}
\def\@makesectionhead#1{%
{\par\vspace{20pt}%
\parindent 0pt\raggedleft\sectionfont
\colorbox{\chpcolor}{%
\parbox[t]{90pt}{\color{white}\@sectionstrut\@depth4.5\p@\hfill
\ifnum\c@secnumdepth>\z@\thesection\fi}%
}%
\begin{minipage}[t]{\dimexpr\textwidth-90pt-2\fboxsep\relax}
\color{\chpcolortxt}\@sectionstrut\hspace{5pt}#1
\end{minipage}\par
\vspace{10pt}%
}
}
\def\section{\@afterindentfalse\secdef\@section\@ssection}
\def\@section[#1]#2{%
\ifnum\c@secnumdepth>\m@ne
\refstepcounter{section}%
\addcontentsline{toc}{section}{\protect\numberline{\thesection}#1}%
\else
\phantomsection
\addcontentsline{toc}{section}{#1}%
\fi
\sectionmark{#1}%
\if@twocolumn
\@topnewpage[\@makesectionhead{#2}]%
\else
\@makesectionhead{#2}\@afterheading
\fi
}
\def\@ssection#1{%
\if@twocolumn
\@topnewpage[\@makesectionhead{#1}]%
\else
\@makesectionhead{#1}\@afterheading
\fi
}
\makeatother
\begin{document}
\chapter{Chapter title}
This is a test.
\section{The Laplace transform}
This is a test.
\end{document}