我想修改,thmbox.sty
因为它不会强调可选键:
\begin{myenvthmboxname}[text I don't want to underline]
But I want to underline the title of the box.
\end{myenvthmboxname}
我尝试了一些修改,但失败了:如果我选择该选项,undeline=true
它会在环境标题和“我不想加下划线的文本”下划线。有什么想法吗?
答案1
经过多次尝试理解代码后,我找到了解决方案。稍后我会尝试解释我做了什么。在简历中,我将可选参数传递给框外的头部框,该框决定了规则的宽度。
thmbox.sty
(复制并保存thmbox.sty
在与文件相同的文件夹中tex
)
%%
%% This is file `thmbox.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% thmbox.dtx
%%
%% This is the thmbox package.
%% (c) Emmanuel Beffara, 2002--2005 (LPPL)
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{thmbox}[2005/04/24 v2.0 fancy theorem outlining]
\RequirePackage{keyval}
\newcommand\thmboxoptions{\setkeys{thmbox}}
\let\thmbox@style=M
\define@key{thmbox}{style}{\let\thmbox@style=#1}
\define@key{thmbox}{S}[]{\let\thmbox@style=S}
\define@key{thmbox}{M}[]{\let\thmbox@style=M}
\define@key{thmbox}{L}[]{\let\thmbox@style=L}
\newdimen\thmbox@leftmargin \thmbox@leftmargin=\parindent
\newdimen\thmbox@rightmargin \thmbox@rightmargin=0pt
\newdimen\thmbox@hskip \thmbox@hskip=.4em
\newdimen\thmbox@vskip \thmbox@vskip=.4em
\newdimen\thmbox@thickness \thmbox@thickness=.6pt
\define@key{thmbox}{leftmargin}{\thmbox@leftmargin=#1\relax}
\define@key{thmbox}{rightmargin}{\thmbox@rightmargin=#1\relax}
\define@key{thmbox}{hskip}{\thmbox@hskip=#1\relax}
\define@key{thmbox}{vskip}{\thmbox@vskip=#1\relax}
\define@key{thmbox}{thickness}{\thmbox@thickness=#1\relax}
\newif\ifthmbox@cut
\thmbox@cuttrue
\define@key{thmbox}{cut}[true]{%
\expandafter\let\expandafter\ifthmbox@cut\csname if#1\endcsname}
\define@key{thmbox}{nocut}[]{\thmbox@cutfalse}
\DeclareOption{cut}{\thmbox@cuttrue}
\DeclareOption{nocut}{\thmbox@cutfalse}
\newif\ifthmbox@underline
\thmbox@underlinetrue
\define@key{thmbox}{underline}[true]{%
\expandafter\let\expandafter\ifthmbox@underline\csname if#1\endcsname}
\define@key{thmbox}{nounderline}[]{\thmbox@underlinefalse}
\DeclareOption{underline}{\thmbox@underlinetrue}
\DeclareOption{nounderline}{\thmbox@underlinefalse}
\newcommand\thmbox@headstyle[2]{\bfseries\boldmath#1 #2}
\define@key{thmbox}{headstyle}{\def\thmbox@headstyle##1##2{#1}}
\newcommand\thmbox@titlestyle[1]{
\if\relax\detokenize{#1}\relax%
\else
\normalfont(\textit{#1\/})%
\fi}
\define@key{thmbox}{titlestyle}{\def\thmbox@titlestyle##1{#1}}
\newcommand\thmbox@bodystyle{\slshape\noindent}
\define@key{thmbox}{bodystyle}{\def\thmbox@bodystyle{#1}}
\newif\ifthmbox@newtheorem
\thmbox@newtheoremtrue
\DeclareOption{nothm}{\thmbox@newtheoremfalse}
\DeclareOption*{\expandafter\thmboxoptions\expandafter{\CurrentOption}}
\ProcessOptions\relax
\newbox\thmbox@box
\newbox\thmbox@box@
\newbox\thmbox@box@@% <---- NEW
\newdimen\thmbox@dim
\def\thmbox@put#1{
\vskip\z@%
\noindent%
\hbox{%
{\dimen0=\thmbox@leftmargin%
\advance\dimen0-\thmbox@hskip%
\advance\dimen0-\thmbox@thickness%
\hskip\dimen0}%
\vrule width \thmbox@thickness%
\hskip\thmbox@hskip%
\box#1%
\ifx\thmbox@style L%
\hskip\thmbox@hskip%
\vrule width \thmbox@thickness%
\fi}%
\par\nobreak}
\def\thmbox@start{%
\ifthmbox@cut%
\ifdim\pagetotal>\vsize%
\thmbox@dim=2\vsize%
\else%
\thmbox@dim=\vsize%
\fi%
\advance\thmbox@dim -\pagetotal%
\ifdim\thmbox@dim>\ht\thmbox@box%
\thmbox@put\thmbox@box%
\else%
\setbox\thmbox@box@=\vsplit\thmbox@box to \thmbox@dim%
\thmbox@put\thmbox@box@%
\thmbox@page%
\fi%
\else%
\thmbox@put\thmbox@box%
\fi}
\def\thmbox@page{%
\ifvoid\thmbox@box%
\else%
\eject%
\ifdim\vsize<\ht\thmbox@box%
\setbox\thmbox@box@=\vsplit\thmbox@box to \vsize%
\thmbox@put\thmbox@box@%
\thmbox@page%
\else%
\thmbox@put\thmbox@box%
\fi%
\fi}
\def\thmbox@head#1#2{%
\par\noindent\vbox{%
\setbox\thmbox@box@=\hbox{%
\vrule width 0mm height 0mm depth \thmbox@vskip %
#1}%
%%%% new box to store the optional argument
\setbox\thmbox@box@@=\hbox{%
% \vrule width 0mm height 0mm depth \thmbox@vskip%
\thmbox@titlestyle{#2} }% optional argument
\hbox{\copy\thmbox@box@\copy\thmbox@box@@}% hbox to put both on the same line
\ifthmbox@underline%
\hrule width \wd\thmbox@box@ height \thmbox@thickness%
\fi }%
\hrule height 0mm\relax}
\def\thmbox@tail{%
\hrule height 0mm%
\ifx\thmbox@style M%
\thmbox@dim=1cm%
\else\ifx\thmbox@style L%
\thmbox@dim=\hsize%
\advance\thmbox@dim-\thmbox@leftmargin%
\advance\thmbox@dim-\thmbox@rightmargin%
\advance\thmbox@dim2\thmbox@hskip%
\advance\thmbox@dim2\thmbox@thickness%
\fi\fi%
\noindent%
{\dimen0=\thmbox@leftmargin%
\advance\dimen0-\thmbox@hskip%
\advance\dimen0-\thmbox@thickness%
\hskip\dimen0}%
\vrule width \thmbox@dim height \thmbox@thickness%
\par}
\newenvironment{thmbox}[3][]{%
\parskip\z@%
\setkeys{thmbox}{#1}%
\ifx\thmbox@style S\else\ifx\thmbox@style M\else\ifx\thmbox@style L\else%
\PackageWarning{thmbox}{\thmbox@style\ is not a valid style for
\string\thmbox, using M}%
\let\thmbox@style=M%
\fi\fi\fi%
\thmbox@head{{#2}}{#3}\nobreak\relax% <--- used 2nd argument in head
\thmbox@dim=\hsize%
\advance\thmbox@dim-\leftskip%
\advance\thmbox@dim-\rightskip%
\setbox\thmbox@box=\vbox\bgroup%
\hsize=\thmbox@dim%
\advance\hsize -\thmbox@leftmargin%
\advance\hsize -\thmbox@rightmargin%
\textwidth=\hsize%
\linewidth=\hsize%
\vskip\thmbox@vskip%
\begingroup}{\endgroup%
\vskip\thmbox@vskip%
\egroup%
\thmbox@start%
\ifx\thmbox@style S\else\thmbox@tail\fi%
\@endparenv}
\newenvironment{leftbar}[1][]{%
\setkeys{thmbox}{#1}%
\par\vskip\thmbox@vskip%
\setbox\thmbox@box=\vbox\bgroup%
\hsize=\textwidth%
\advance\hsize -\thmbox@leftmargin%
\advance\hsize -\thmbox@rightmargin%
\begingroup}{\endgroup%
\vskip\thmbox@vskip%
\egroup%
\thmbox@start%
\vskip\thmbox@vskip\par}
\def\newboxtheorem{%
\@ifnextchar[{\thmbox@newA}{\thmbox@newA[]}}%
\def\thmbox@newA[#1]#2{%
\def\thmbox@temp##1{#1}%
\@ifnextchar[{\thmbox@newC{#2}}{\thmbox@newD{#2}}}
\def\thmbox@newC#1[#2]#3{%
\expandafter\thmbox@new\expandafter{\thmbox@temp{####1}}{#1}{#3}{#2}}
\def\thmbox@newD#1#2{%
\@ifnextchar[{\thmbox@newE{#1}{#2}}{%
\newcounter{#1}%
\expandafter\thmbox@new\expandafter{\thmbox@temp{####1}}{#1}{#2}{#1}}}
\def\thmbox@newE#1#2[#3]{%
\newcounter{#1}[#3]%
\expandafter\def\csname the#1\endcsname{%
\csname the#3\endcsname.\arabic{#1}}
\expandafter\thmbox@new\expandafter{\thmbox@temp{####1}}{#1}{#2}{#1}}
\def\thmbox@new#1#2#3#4{%
\expandafter\def\csname#2\endcsname{%
\setkeys{thmbox}{#1}%
\@ifnextchar[{\thmbox@beginA{#3}{#4}}{%
\thmbox@begin{#3}{#4}{}}}%
\expandafter\def\csname end#2\endcsname{%
\endthmbox\smallbreak}}
\def\thmbox@beginA#1#2[#3]{%
\thmbox@begin{#1}{#2}{#3}}
\def\thmbox@begin#1#2#3{%
\medbreak%
\refstepcounter{#2}%
\thmbox{\thmbox@headstyle{#1}{\csname the#2\endcsname}}{#3}% 3rd used outside the thmbox
\thmbox@bodystyle\ignorespaces}
\ifthmbox@newtheorem
\let\newtheorem\newboxtheorem
\fi
\def\example{}
\@ifundefined{examplename}{\def\examplename{Example}}{}
\renewenvironment{example}[1][\examplename]{%
\par\smallbreak\small%
\list{\hspace\labelsep\textbf{#1\,:}}{%
\leftmargin=\parindent%
\labelwidth=\parindent}%
\item\relax}{%
\endlist}
\def\proof{}
\@ifundefined{proofname}{\def\proofname{Proof}}{}
\renewenvironment{proof}[1][]{%
\small%
\list{\hspace\labelsep\textbf{\proofname\ #1\unskip\,:}}{%
\topsep=\smallskipamount%
\partopsep=0pt%
\leftmargin=\parindent%
\rightmargin=\parindent%
\listparindent=\parindent%
\labelwidth=\parindent}%
\item\relax\ignorespaces}%
{\parskip\z@%
\par\noindent%
\setbox\thmbox@box=\hbox{%
\kern .5em\vbox{%
\hrule width .7em height .7em
\vskip\baselineskip}}%
\wd\thmbox@box=0mm%
\ht\thmbox@box=0mm%
\hfill\box\thmbox@box%
\endlist\par}
\endinput
%%
%% End of file `thmbox.sty'.