我是 tex 世界的新人。
我正在将 markdown 转换为 pdf,首先使用 pandoc 创建文本,然后ConText
生成 pdf。如果我能解决一些问题,我希望将模板发布给更广泛的 pandoc 受众。
当我添加\setuppagenumbering[location=]
到模板以删除页眉中的默认页码时,出现以下错误。还附上了 tex 文件供您参考。
mtx-context | run 1: luatex --fmt="C:/Programs/context/context/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0
dde776fb1556f32e/formats/luatex/cont-en" --interaction="nonstopmode" --jobname="taf-user-guide10" --lua="C:/Programs/con
text/context/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en.lui" --no-pars
e-first-line --c:currentrun=1 --c:fulljobname="./taf-user-guide10.tex" --c:input="./taf-user-guide10.tex" --c:kindofrun=
1 --c:maxnofruns=8 --c:nonstopmode "cont-yes.mkiv"
This is LuaTeX, Version beta-0.79.1 (TeX Live 2014/W32TeX) (rev 5041)
\write18 enabled.
open source > 1 > 1 > C:/Programs/context/context/tex/texmf-context/tex/context/base/cont-yes.mkiv
ConTeXt ver: 2014.09.06 20:59 MKIV beta fmt: 2014.9.8 int: english/english
system > 'cont-new.mkiv' loaded
open source > 2 > 2 > C:/Programs/context/context/tex/texmf-context/tex/context/base/cont-new.mkiv
close source > 2 > 2 > C:/Programs/context/context/tex/texmf-context/tex/context/base/cont-new.mkiv
system > files > jobname 'taf-user-guide10', input './taf-user-guide10', result 'taf-user-guide10'
fonts > latin modern fonts are not preloaded
languages > language 'en' is active
open source > 2 > 3 > C:/Project/meccano/trunk/docs/user manual/taf-user-guide10.tex
open source > 3 > 4 > C:/Programs/context/context/tex/texmf-context/tex/context/base/type-imp-texgyre.mkiv
close source > 3 > 4 > C:/Programs/context/context/tex/texmf-context/tex/context/base/type-imp-texgyre.mkiv
fonts > bodyfont '20pt' is defined (can better be done global)
fonts > bodyfont '24pt' is defined (can better be done global)
fonts > bodyfont '16pt' is defined (can better be done global)
backend > xmp > using file 'C:/Programs/context/context/tex/texmf-context/tex/context/base/lpdf-pdx.xml'
pages > flushing realpage 1, userpage 1
pages > flushing realpage 2, userpage 2
structure > sectioning > title @ level 2 : 0.0 -> \headtext {content}
pages > flushing realpage 3, userpage 3
lua error > error on line 150 in file C:/Project/meccano/trunk/docs/user manual/taf-user-guide10.tex:
.../context/tex/texmf-context/tex/context/base/strc-doc.lua:904: attempt to index field 'numbers' (a nil value)
stack traceback:
.../context/tex/texmf-context/tex/context/base/strc-doc.lua:904: in function 'getsectionnumber'
[\directlua]:1: in main chunk
140 {\tfd {\switchtobodyfont [20pt] TAF User Guide}}
141 \blank[5*big]
142 {\tfa abc}
143 \blank[2*big]
144 {\tfa \currentdate}
145 \blank[3*medium]
146 \stopalignment
147
148 \completecontent
149
150 >> \chapter{Creating device driver}
151 \section[how-to-create-the]{How to create the}
152
153 asdasdasd adasd a
154
155 \stoptext
pandoc 生成的 Tex 文件,使用以下方式转换为 pdfContext
\startmode[*mkii]
\enableregime[utf-8]
\setupcolors[state=start]
\stopmode
% COLOR==================================================
\definecolor [darktheme] [r=0.43, g=0.00, b=0.00]\definecolor [blockquotebackground] [r=0.85, g=0.65, b=0.55]\definecolor [codebackground] [r=0.95, g=0.95, b=1.00]% Enable hyperlinks======================================
\setupinteraction[state=start, color=darktheme]
% PAGE SETUP ================================================
\setuppapersize [A4][A4]
\setuplayout [width=middle, backspace=1in, cutspace=1in, height=middle, topspace=0.75in, bottomspace=0.75in]
% HEADER ================================================
%\setupheadertexts[][][][]
\setupfootertexts[\setups{text right}][][][\setups{text left}]
\setuppagenumbering[location=,alternative=doublesided]
\startsetups[text right]
\rlap{}
\hfill
\bf {\sl {TAF User Guide} (420) }
\hfill
\llap{\pagenumber}
\stopsetups
\startsetups[text left]
\rlap{\pagenumber}
\hfill
\bf \cap{ Chapter \namedheadnumber{chapter} } \getmarking[chapter]
\hfill
\llap{}
\stopsetups
% BODY ======================================================
\setupbodyfont[palatino,11pt]
\setupwhitespace[medium]
% HEADINGS ==================================================
\unexpanded\def\HeadTitle#1#2%
{\hbox to \hsize \bgroup
\hfill
\setupframed[offset=.5em,frame=off]
\tbox{\framed[width=2cm,align=left]{#1}}%
\tbox{\framed[width=7cm,align=right,leftframe=on]{#2}}%
\egroup}
\setupheads[alternative=inmargin,separator=--,color=darktheme]
\setuphead[chapter] [style=\tfd \bf, command=\HeadTitle, textstyle=bold]
\setuphead[section] [style=\tfb \bf]
\setuphead[subsection] [style=\tf \bolditalic]
\setuphead[subsubsection][style=\bf, number=no]
% BLOCKQUOTE ================================================
\definebackground
[blockquote]
[
framecolor=darktheme,
background=color,
backgroundcolor=blockquotebackground,
frame=off,
leftframe=on,
rulethickness=2mm,
offset=overlay,
leftoffset=2em,
rightoffset=1em,
width=\textwidth,
setups=framedsetups,
before=\blank,
after=\blank,
]
% CODE ================================================
\definetextbackground
[verbatim]
[
background=color,
backgroundcolor=codebackground,
backgroundoffset=0mm,
offset=0.8cm,
frame=off,
location=paragraph,
before=\blank,
after=\blank,
]
\setuptyping
[typing]
[margin=2mm,bodyfont=10.0pt,
before={\starttextbackground[verbatim]},
after={\stoptextbackground}]
\definedescription
[description]
[headstyle=bold, style=normal, location=hanging, width=broad, margin=1cm]
\setupitemize[autointro] % prevent orphan list intro
\setupitemize[indentnext=no]
\setupfloats[figure][location=left,width=6.3in]
\setupfloats[table][default={here}]
\setupcaptions[figure][style=bold]
\setupthinrules[width=15em] % width of horizontal rules
\setupdelimitedtext
[blockquote]
[before={\blank[medium]},
after={\blank[medium]},
indentnext=no,
]
% TOC======================================================
\setupcombinedlist[content][list={chapter,section,subsection}]
% level=4, \subsubsubsections are not listed in ToC
% alternative=c, space to the page number is filled with dots
\setupcombinedlist[content][list={chapter,section}, alternative=c,]
\setuplist[chapter][width=10mm, style=bold]
\setuplist[section][width=20mm, style=normal, pagestyle=normal]
%\setuplist[subsection][width=20mm, style=slanted, pagestyle=normal]
% pagestyle=normal for changing the appearance of pagenumber
%\setuplist[subsubsection][width=20mm, style=slanted, pagestyle=normal]
\starttext
\startalignment[center]
\blank[4*big]
{\tfd {\switchtobodyfont [20pt] TAF User Guide}}
\blank[5*big]
{\tfa abc}
\blank[2*big]
{\tfa \currentdate}
\blank[3*medium]
\stopalignment
\completecontent
\chapter{Creating device driver}
\section[how-to-create-the]{How to create the}
asdasdasd adasd a
\stoptext
这是一个显示相同错误消息的最小示例。
\setupfootertexts[\namedheadnumber{chapter}]
\setuppagenumbering[location=,alternative=doublesided]
\starttext
\completecontent
\chapter{Creating device driver}
\section{How to create the}
Chapter text
\stoptext
答案1
来自上下文邮件列表的 Wolfgang Schuster 的回答。
只有在没有.tuc
文件时才会发生错误。最简单的解决方法是使用
\getmarking[chapternumber]
代替
\namedheadnumber{chapter}