我试图只为定理和推论的数字部分着色。经过一番调整,我能够制作出以下图像,我对此几乎感到满意
在下面的代码中我有一行
headformat = \textcolor{\numberColor}{\NUMBER},
我想用
headformat = \NAME \textcolor{UiT-main}{\NUMBER},
还可以获得姓名定理。但是,这会给我一个错误,因为 NAME 没有用 定义ntheorem
。结果如下所示
- 是否有其他方法可以为我的定理获取彩色数字,或者是否有办法找到
NAME
替代方法ntheorem
?
代码
\documentclass[a4paper]{article}
\usepackage{mathtools,amsmath,amssymb}
\usepackage[amsmath,amsthm,thmmarks]{ntheorem}
\usepackage{thmtools}
\usepackage{xcolor}
\definecolor{UiT-main}{HTML}{003349}
\definecolor{UiT-blue}{HTML}{007396}
\newcommand{\numberColor}{UiT-blue}
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\Large\bfseries\color{black}}{\color{\numberColor}\thesection}{1em}{}
\declaretheoremstyle[
spaceabove = 7mm,
spacebelow = 7mm,
headfont = \color{black}\normalfont\bfseries,
headformat = \textcolor{\numberColor}{\NUMBER},
% headformat = \NAME \textcolor{UiT-main}{\NUMBER}, % uncomment for error
headpunct = {},
bodyfont = \normalfont\itshape
]{plainColored}
\newcounter{dummy}
\numberwithin{dummy}{section}
\theoremstyle{plainColored}
\newtheorem{example}[dummy]{Example}
\newtheorem{lemma}[dummy]{Lemma}
\newtheorem{theorem}[dummy]{Theorem}
\newtheorem{proposition}[dummy]{Proposition}
\newtheorem{corollary}[dummy]{Corollary}
\begin{document}
\section{First section}
\begin{theorem}
\end{theorem}
\begin{lemma}
\end{lemma}
\begin{proposition}
\end{proposition}
\end{document}
错误消息的 Rawlog
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex 2017.7.12) 7 JUL 2019 16:29
entering extended mode
\write18 enabled.
%&-line parsing enabled.
**testColors.tex
(/compile/testColors.tex
LaTeX2e <2017-04-15>
Babel <3.12> and hyphenation patterns for 84 language(s) loaded.
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
) (/usr/local/texlive/2017/texmf-dist/tex/latex/mathtools/mathtools.sty
Package: mathtools 2017/05/24 v1.19 mathematical typesetting tools
(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks14
) (/usr/local/texlive/2017/texmf-dist/tex/latex/tools/calc.sty
Package: calc 2014/10/28 v4.3 Infix arithmetic (KKT,FJ)
\calc@Acount=\count87
\calc@Bcount=\count88
\calc@Adimen=\dimen103
\calc@Bdimen=\dimen104
\calc@Askip=\skip43
\calc@Bskip=\skip44
LaTeX Info: Redefining \setlength on input line 80.
LaTeX Info: Redefining \addtolength on input line 81.
\calc@Ccount=\count89
\calc@Cskip=\skip45
) (/usr/local/texlive/2017/texmf-dist/tex/latex/mathtools/mhsetup.sty
Package: mhsetup 2017/03/31 v1.3 programming setup (MH)
) (/usr/local/texlive/2017/texmf-dist/tex/latex/amsmath/amsmath.sty
Package: amsmath 2016/11/05 v2.16a AMS math features
\@mathmargin=\skip46
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2017/texmf-dist/tex/latex/amsmath/amstext.sty
Package: amstext 2000/06/29 v2.01 AMS text
(/usr/local/texlive/2017/texmf-dist/tex/latex/amsmath/amsgen.sty
File: amsgen.sty 1999/11/30 v2.0 generic functions
\@emptytoks=\toks15
\ex@=\dimen105
)) (/usr/local/texlive/2017/texmf-dist/tex/latex/amsmath/amsbsy.sty
Package: amsbsy 1999/11/29 v1.2d Bold Symbols
\pmbraise@=\dimen106
) (/usr/local/texlive/2017/texmf-dist/tex/latex/amsmath/amsopn.sty
Package: amsopn 2016/03/08 v2.02 operator names
)
\inf@bad=\count90
LaTeX Info: Redefining \frac on input line 213.
\uproot@=\count91
\leftroot@=\count92
LaTeX Info: Redefining \overline on input line 375.
\classnum@=\count93
\DOTSCASE@=\count94
LaTeX Info: Redefining \ldots on input line 472.
LaTeX Info: Redefining \dots on input line 475.
LaTeX Info: Redefining \cdots on input line 596.
\Mathstrutbox@=\box26
\strutbox@=\box27
\big@size=\dimen107
LaTeX Font Info: Redeclaring font encoding OML on input line 712.
LaTeX Font Info: Redeclaring font encoding OMS on input line 713.
\macc@depth=\count95
\c@MaxMatrixCols=\count96
\dotsspace@=\muskip10
\c@parentequation=\count97
\dspbrk@lvl=\count98
\tag@help=\toks16
\row@=\count99
\column@=\count100
\maxfields@=\count101
\andhelp@=\toks17
\eqnshift@=\dimen108
\alignsep@=\dimen109
\tagshift@=\dimen110
\tagwidth@=\dimen111
\totwidth@=\dimen112
\lineht@=\dimen113
\@envbody=\toks18
\multlinegap=\skip47
\multlinetaggap=\skip48
\mathdisplay@stack=\toks19
LaTeX Info: Redefining \[ on input line 2817.
LaTeX Info: Redefining \] on input line 2818.
)
LaTeX Info: Thecontrolsequence`\('isalreadyrobust on input line 129.
LaTeX Info: Thecontrolsequence`\)'isalreadyrobust on input line 129.
LaTeX Info: Thecontrolsequence`\['isalreadyrobust on input line 129.
LaTeX Info: Thecontrolsequence`\]'isalreadyrobust on input line 129.
\g_MT_multlinerow_int=\count102
\l_MT_multwidth_dim=\dimen114
\origjot=\skip49
\l_MT_shortvdotswithinadjustabove_dim=\dimen115
\l_MT_shortvdotswithinadjustbelow_dim=\dimen116
\l_MT_above_intertext_sep=\dimen117
\l_MT_below_intertext_sep=\dimen118
\l_MT_above_shortintertext_sep=\dimen119
\l_MT_below_shortintertext_sep=\dimen120
) (/usr/local/texlive/2017/texmf-dist/tex/latex/amsfonts/amssymb.sty
Package: amssymb 2013/01/14 v3.01 AMS font symbols
(/usr/local/texlive/2017/texmf-dist/tex/latex/amsfonts/amsfonts.sty
Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support
\symAMSa=\mathgroup4
\symAMSb=\mathgroup5
LaTeX Font Info: Overwriting math alphabet `\mathfrak' in version `bold'
(Font) U/euf/m/n --> U/euf/b/n on input line 106.
)) (/usr/local/texlive/2017/texmf-dist/tex/latex/ntheorem/ntheorem.sty
Style `ntheorem', Version 1.33 <2011/08/15>
Package: ntheorem 2011/08/15 1.33
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/ifthen.sty
Package: ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
)
\theorem@style=\toks20
\theorem@@style=\toks21
\theorembodyfont=\toks22
\theoremnumbering=\toks23
\theorempreskipamount=\skip50
\theorempostskipamount=\skip51
\theoremframepreskipamount=\skip52
\theoremframepostskipamount=\skip53
\theoreminframepreskipamount=\skip54
\theoreminframepostskipamount=\skip55
\theorem@preskip=\toks24
\theorem@postskip=\toks25
\theorem@framepreskip=\toks26
\theorem@framepostskip=\toks27
\theorem@inframepreskip=\toks28
\theorem@inframepostskip=\toks29
\theoremindent=\dimen121
\theorem@indent=\dimen122
\theoremrightindent=\dimen123
\theorem@rightindent=\dimen124
\theoremheaderfont=\toks30
\theoremseparator=\toks31
\theoremprework=\toks32
\theorempostwork=\toks33
\theoremsymbol=\toks34
\qedsymbol=\toks35
\theoremkeyword=\toks36
\qedsymbol=\toks37
\thm@topsep=\skip56
\thm@topsepadd=\skip57
Package ntheorem Info: Option `thmmarks' loaded on input line 1175.
\c@endNonectr=\count103
\c@currNonectr=\count104
\mysavskip=\skip58
Package ntheorem Info: option `amsmath' handling for `thmmarks' loaded on input
line 1175.
\thm@amstmpdepth=\dimen125
\tagwidth=\dimen126
Package ntheorem Info: Option `amsthm' loaded on input line 1175.
\c@proof=\count105
\c@currproofctr=\count106
\c@endproofctr=\count107
) (/usr/local/texlive/2017/texmf-dist/tex/latex/thmtools/thmtools.sty
Package: thmtools 2014/04/21 v66
\thmt@toks=\toks38
\c@thmt@dummyctr=\count108
(/usr/local/texlive/2017/texmf-dist/tex/latex/thmtools/thm-patch.sty
Package: thm-patch 2014/04/21 v66
(/usr/local/texlive/2017/texmf-dist/tex/latex/thmtools/parseargs.sty
Package: parseargs 2014/04/21 v66
\@parsespec=\toks39
)) (/usr/local/texlive/2017/texmf-dist/tex/latex/thmtools/thm-kv.sty
Package: thm-kv 2014/04/21 v66
Package thm-kv Info: Theorem names will be uppercased on input line 40.
(/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO)
(/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/infwarerr.sty
Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)
) (/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/etexcmds.sty
Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
(/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/ifluatex.sty
Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
Package ifluatex Info: LuaTeX not detected.
)
Package etexcmds Info: Could not find \expanded.
(etexcmds) That can mean that you are not using pdfTeX 1.50 or
(etexcmds) that some package has redefined \expanded.
(etexcmds) In the latter case, load this package earlier.
))
Package thm-kv Info: kvsetkeys patch (v1.16 or later) on input line 156.
) (/usr/local/texlive/2017/texmf-dist/tex/latex/thmtools/thm-autoref.sty
Package: thm-autoref 2014/04/21 v66
(/usr/local/texlive/2017/texmf-dist/tex/latex/thmtools/aliasctr.sty
Package: aliasctr 2014/04/21 v66
(/usr/local/texlive/2017/texmf-dist/tex/latex/carlisle/remreset.sty))) (/usr/lo
cal/texlive/2017/texmf-dist/tex/latex/thmtools/thm-listof.sty
Package: thm-listof 2014/04/21 v66
) (/usr/local/texlive/2017/texmf-dist/tex/latex/thmtools/thm-restate.sty
Package: thm-restate 2014/04/21 v66
) (/usr/local/texlive/2017/texmf-dist/tex/latex/thmtools/thm-ntheorem.sty
Package: thm-ntheorem 2014/04/21 v66
)) (/usr/local/texlive/2017/texmf-dist/tex/latex/xcolor/xcolor.sty
Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK)
(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics-cfg/color.cfg
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package xcolor Info: Driver file: pdftex.def on input line 225.
(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics-def/pdftex.def
File: pdftex.def 2017/06/24 v1.0g Graphics/color driver for pdftex
)
Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348.
Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1352.
Package xcolor Info: Model `RGB' extended on input line 1364.
Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366.
Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367.
Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368.
Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369.
Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370.
Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371.
) (/usr/local/texlive/2017/texmf-dist/tex/latex/titlesec/titlesec.sty
Package: titlesec 2016/03/21 v2.10.2 Sectioning titles
\ttl@box=\box28
\beforetitleunit=\skip59
\aftertitleunit=\skip60
\ttl@plus=\dimen127
\ttl@minus=\dimen128
\ttl@toksa=\toks40
\titlewidth=\dimen129
\titlewidthlast=\dimen130
\titlewidthfirst=\dimen131
)
\c@dummy=\count109
\c@currexamplectr=\count110
\c@endexamplectr=\count111
\c@currlemmactr=\count112
\c@endlemmactr=\count113
\c@currtheoremctr=\count114
\c@endtheoremctr=\count115
\c@currpropositionctr=\count116
\c@endpropositionctr=\count117
\c@currcorollaryctr=\count118
\c@endcorollaryctr=\count119
(/compile/output.aux)
\openout1 = `output.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 37.
LaTeX Font Info: ... okay on input line 37.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 37.
LaTeX Font Info: ... okay on input line 37.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 37.
LaTeX Font Info: ... okay on input line 37.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 37.
LaTeX Font Info: ... okay on input line 37.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 37.
LaTeX Font Info: ... okay on input line 37.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 37.
LaTeX Font Info: ... okay on input line 37.
(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics/graphicx.sty
Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics/graphics.sty
Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics/trig.sty
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
) (/usr/local/texlive/2017/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 99.
)
\Gin@req@height=\dimen132
\Gin@req@width=\dimen133
) (/usr/local/texlive/2017/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count120
\scratchdimen=\dimen134
\scratchbox=\box29
\nofMPsegments=\count121
\nofMParguments=\count122
\everyMPshowfont=\toks41
\MPscratchCnt=\count123
\MPscratchDim=\dimen135
\MPnumerator=\count124
\makeMPintoPDFobject=\count125
\everyMPtoPDFconversion=\toks42
) (/usr/local/texlive/2017/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf
(/usr/local/texlive/2017/texmf-dist/tex/latex/oberdiek/grfext.sty
Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO)
(/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty
Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO)
(/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/ltxcmds.sty
Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
))) (/usr/local/texlive/2017/texmf-dist/tex/latex/oberdiek/kvoptions.sty
Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO)
) (/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
Package: pdftexcmds 2017/03/19 v0.25 Utility functions of pdfTeX for LuaTeX (HO
)
(/usr/local/texlive/2017/texmf-dist/tex/generic/oberdiek/ifpdf.sty
Package: ifpdf 2017/03/15 v3.2 Provides the ifpdf switch
)
Package pdftexcmds Info: LuaTeX not detected.
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
)
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
38.
Package grfext Info: Graphics extension search list:
(grfext) [.pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.JPG,.JPE
G,.JBIG2,.JB2,.eps]
(grfext) \AppendGraphicsExtensions on input line 456.
(/usr/local/texlive/2017/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg
File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv
e
))
! Undefined control sequence.
\NAME ->\the \thm@headfont
Theorem
l.42
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! You can't use `the letter T' after \the.
\NAME ->\the \thm@headfont T
heorem
l.42
I'm forgetting what you said and using zero instead.
LaTeX Font Info: Try loading font information for U+msa on input line 42.
(/usr/local/texlive/2017/texmf-dist/tex/latex/amsfonts/umsa.fd
File: umsa.fd 2013/01/14 v3.01 AMS symbols A
)
LaTeX Font Info: Try loading font information for U+msb on input line 42.
(/usr/local/texlive/2017/texmf-dist/tex/latex/amsfonts/umsb.fd
File: umsb.fd 2013/01/14 v3.01 AMS symbols B
)
! Undefined control sequence.
\NAME ->\the \thm@headfont
Lemma
l.46
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! You can't use `the letter L' after \the.
\NAME ->\the \thm@headfont L
emma
l.46
I'm forgetting what you said and using zero instead.
! Undefined control sequence.
\NAME ->\the \thm@headfont
Proposition
l.50
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! You can't use `the letter P' after \the.
\NAME ->\the \thm@headfont P
roposition
l.50
I'm forgetting what you said and using zero instead.
\tf@thm=\write3
\openout3 = `output.thm'.
[1
{/usr/local/texlive/2017/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (/compi
le/output.aux) )
Here is how much of TeX's memory you used:
4425 strings out of 492990
63420 string characters out of 6132621
129659 words of memory out of 5000000
7900 multiletter control sequences out of 15000+600000
6598 words of font info for 26 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
38i,5n,35p,289b,192s stack positions out of 5000i,500n,10000p,200000b,80000s
</usr/local/texlive/2017/texmf-dist/fonts/type1/public/amsfonts
/cm/cmbx10.pfb></usr/local/texlive/2017/texmf-dist/fonts/type1/public/amsfonts/
cm/cmbx12.pfb></usr/local/texlive/2017/texmf-dist/fonts/type1/public/amsfonts/c
m/cmr10.pfb>
Output written on /compile/output.pdf (1 page, 28765 bytes).
PDF statistics:
20 PDF objects out of 1000 (max. 8388607)
13 compressed objects within 1 object stream
0 named destinations out of 1000 (max. 500000)
1 words of extra memory for PDF output out of 10000 (max. 10000000)
答案1
错误说
! Undefined control sequence.
\NAME ->\the \thm@headfont
Theorem
这意味着\thm@headfont
未定义,而不是\NAME
。
解决方案:定义它。它应该是一个可以留空的令牌寄存器。在示例中,我将颜色更改UiT-main
为red
,因此输出清晰可见。
\documentclass[a4paper]{article}
\usepackage{mathtools,amsmath,amssymb}
\usepackage[amsmath,thmmarks]{ntheorem}
\usepackage{thmtools}
\usepackage{xcolor}
\definecolor{UiT-main}{HTML}{003349}
\definecolor{UiT-blue}{HTML}{007396}
\newcommand{\numberColor}{UiT-blue}
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\Large\bfseries\color{black}}{\color{\numberColor}\thesection}{1em}{}
\makeatletter
\newtoks\thm@headfont
\makeatother
\declaretheoremstyle[
spaceabove = 7mm,
spacebelow = 7mm,
headfont = \color{black}\normalfont\bfseries,
headformat = \NAME\ \textcolor{red}{\NUMBER},
headpunct = {},
bodyfont = \normalfont\itshape
]{plainColored}
\newcounter{dummy}
\numberwithin{dummy}{section}
\theoremstyle{plainColored}
\newtheorem{example}[dummy]{Example}
\newtheorem{lemma}[dummy]{Lemma}
\newtheorem{theorem}[dummy]{Theorem}
\newtheorem{proposition}[dummy]{Proposition}
\newtheorem{corollary}[dummy]{Corollary}
\begin{document}
\section{First section}
\begin{theorem}
\end{theorem}
\begin{lemma}
\end{lemma}
\begin{proposition}
\end{proposition}
\end{document}