在尝试嵌入之前,我的主文档中一切正常这个答案在我的代码中。但是,我不太明白根据此解决方案。
错误信息是
字体 \TU/LatinModernRoman(0)/bx/n/10=LatinModernRoman/B:mode=node;script=latn;language=DFLT;+tlig;-liga; 在 10pt 处无法加载:未找到度量数据或数据错误。\section*{编辑器注释}
PS 我正在使用 MikTeX 2.9 在 Win 10 上进行编译。
\documentclass{elsarticle}
\usepackage{mathtools}
\usepackage[tuenc,no-math]{fontspec}
\usepackage[bold-style=TeX]{unicode-math}
\setmathfont[math-style=ISO]{Cambria Math}
\setmainfont[
Ligatures={NoRequired,
NoCommon,
NoContextual}
]{Latin Modern Roman}
\usepackage[hidelinks,colorlinks=false,bookmarks=true]{hyperref}
\usepackage[numbered]{bookmark}
\biboptions{square,numbers,sort&compress}
\setlength\marginparwidth{0.8\dimexpr(\paperwidth - \textwidth)/2\relax}
\usepackage[textwidth=\marginparwidth]{todonotes}
\usepackage{etoolbox}
\makeatletter
\newcommand\@todonotes@owner{default}
\define@key{todonotes}%
{owner}{\def\@todonotes@owner{#1}}
\newtoggle{ownerdefault}
\newtoggle{ownerB}
\newtoggle{ownerEditor}
\newcommand\stR[2]{% 1st reviewer comment
\todo[%
owner=default,
author=Reviewer \#1,noline,caption={#1 Comment},color=blue!20%
]%
{#1 Comment}{\color{blue}{\bfseries#2}}}
\newcommand\ndR[2]{% 2nd reviewer comment
\todo[%
owner=B,
author=Reviewer \#2,noline,caption={#1 Comment},color=red!50!white%
]%
{#1 Comment}{\color{red}{\bfseries#2}}}
\newcommand\stEditor[2]{% editor comment
\todo[%
owner=Editor,
author=Editor,noline,caption={#1 Comment},color=red!50!white% color of margin note
]%
{#1 Comment}{\color{red}{\bfseries#2}}}% color of comment text
\renewcommand{\@todonotes@addElementToListOfTodos}{%
\if@todonotes@colorinlistoftodos%
\addtocontents{tdo}
{%
\protect\iftoggle{owner\@todonotes@owner}
{%
\protect\contentsline {todo}
{\protect\fcolorbox{\@todonotes@currentbordercolor}%
{\@todonotes@currentbackgroundcolor}%
{\protect\textcolor{\@todonotes@currentbackgroundcolor}{o}}%
\ \@todonotes@caption
}{\thepage}{\@currentHref}%
}{}%
}%
\else%
\addtocontents{tdo}
{%
\protect\iftoggle{owner\@todonotes@owner}
{%
\protect\contentsline {todo}
{\@todonotes@caption
}{\thepage}{\@currentHref}%
}{}%
}%
\fi}%
\makeatother
\usepackage{luacode}
\begin{luacode*}
function sort_tdo (jobname)
local lines = {}
-- read the lines in table 'lines'
for line in io.lines(jobname) do
table.insert(lines, line)
end
-- sort
table.sort(lines)
-- write all the lines
file=io.open(jobname.."sorted", "w")
io.output(file)
for i, l in ipairs(lines) do io.write(l, "\n")
end
io.close(file)
end
\end{luacode*}
\IfFileExists{\jobname.tdo}{\directlua{sort_tdo("\jobname.tdo")}}{}
\makeatletter
\newcommand*{\sectionbookmark}[1][]{%
\bookmark[%
level=section,%
dest=\@currentHref,%
#1%
]%
}
\makeatother
\begin{document}
\pagenumbering{gobble}% Remove page numbers (and reset to 1)
\clearpage
\thispagestyle{empty}
\toggletrue{ownerEditor}
\section*{Editor Comment}
\sectionbookmark{Editor Comment}
\InputIfFileExists{\jobname.tdosorted}{}
\toggletrue{ownerdefault}
\togglefalse{ownerEditor}
\section*{Reviewer \#1 Comments}
\sectionbookmark{Reviewer \#1 Comments}
\InputIfFileExists{\jobname.tdosorted}{}
\toggletrue{ownerB}
\togglefalse{ownerdefault}
\section*{Reviewer \#2 Comments}
\sectionbookmark{Reviewer \#2 Comments}
\InputIfFileExists{\jobname.tdosorted}{}
\togglefalse{ownerB}
\makeatletter \@starttoc{tdo}\makeatother % to trigger the creation of the list
\clearpage
\pagenumbering{arabic}
\stR{1st}{reviewer} some text
\stEditor{1st}{editor} some text
\end{document}
答案1
在 LuaLaTeX 中,全局变量file
用于file
从 访问库lualibs
。如果您的代码发生更改file
,则无法再访问库,从而破坏 luaotfload。
您可以通过本地修复此问题file
:
代替
file=io.open(jobname.."sorted", "w")
写
local file=io.open(jobname.."sorted", "w")
此外,您的文档使用 更改了 Lua 的默认输出文件io.output(...)
。这也会破坏所有其他尝试使用默认输出打印到终端的 Lua 代码。相反,您可以用io.write
替换file:write
。
这引出了以下文件:
\documentclass{elsarticle}
\usepackage{mathtools}
\usepackage[tuenc,no-math]{fontspec}
\usepackage[bold-style=TeX]{unicode-math}
\setmathfont[math-style=ISO]{Cambria Math}
\setmainfont[
Ligatures={NoRequired,
NoCommon,
NoContextual}
]{Latin Modern Roman}
\usepackage[hidelinks,colorlinks=false,bookmarks=true]{hyperref}
\usepackage[numbered]{bookmark}
\biboptions{square,numbers,sort&compress}
\setlength\marginparwidth{0.8\dimexpr(\paperwidth - \textwidth)/2\relax}
\usepackage[textwidth=\marginparwidth]{todonotes}
\usepackage{etoolbox}
\makeatletter
\newcommand\@todonotes@owner{default}
\define@key{todonotes}%
{owner}{\def\@todonotes@owner{#1}}
\newtoggle{ownerdefault}
\newtoggle{ownerB}
\newtoggle{ownerEditor}
\newcommand\stR[2]{% 1st reviewer comment
\todo[%
owner=default,
author=Reviewer \#1,noline,caption={#1 Comment},color=blue!20%
]%
{#1 Comment}{\color{blue}{\bfseries#2}}}
\newcommand\ndR[2]{% 2nd reviewer comment
\todo[%
owner=B,
author=Reviewer \#2,noline,caption={#1 Comment},color=red!50!white%
]%
{#1 Comment}{\color{red}{\bfseries#2}}}
\newcommand\stEditor[2]{% editor comment
\todo[%
owner=Editor,
author=Editor,noline,caption={#1 Comment},color=red!50!white% color of margin note
]%
{#1 Comment}{\color{red}{\bfseries#2}}}% color of comment text
\renewcommand{\@todonotes@addElementToListOfTodos}{%
\if@todonotes@colorinlistoftodos%
\addtocontents{tdo}
{%
\protect\iftoggle{owner\@todonotes@owner}
{%
\protect\contentsline {todo}
{\protect\fcolorbox{\@todonotes@currentbordercolor}%
{\@todonotes@currentbackgroundcolor}%
{\protect\textcolor{\@todonotes@currentbackgroundcolor}{o}}%
\ \@todonotes@caption
}{\thepage}{\@currentHref}%
}{}%
}%
\else%
\addtocontents{tdo}
{%
\protect\iftoggle{owner\@todonotes@owner}
{%
\protect\contentsline {todo}
{\@todonotes@caption
}{\thepage}{\@currentHref}%
}{}%
}%
\fi}%
\makeatother
\usepackage{luacode}
\begin{luacode*}
function sort_tdo (jobname)
local lines = {}
-- read the lines in table 'lines'
for line in io.lines(jobname) do
table.insert(lines, line)
end
-- sort
table.sort(lines)
-- write all the lines
local file=io.open(jobname.."sorted", "w")
for i, l in ipairs(lines) do file:write(l, "\n")
end
file:close()
end
\end{luacode*}
\IfFileExists{\jobname.tdo}{\directlua{sort_tdo("\jobname.tdo")}}{}
\makeatletter
\newcommand*{\sectionbookmark}[1][]{%
\bookmark[%
level=section,%
dest=\@currentHref,%
#1%
]%
}
\makeatother
\begin{document}
\pagenumbering{gobble}% Remove page numbers (and reset to 1)
\clearpage
\thispagestyle{empty}
\toggletrue{ownerEditor}
\section*{Editor Comment}
\sectionbookmark{Editor Comment}
\InputIfFileExists{\jobname.tdosorted}{}
\toggletrue{ownerdefault}
\togglefalse{ownerEditor}
\section*{Reviewer \#1 Comments}
\sectionbookmark{Reviewer \#1 Comments}
\InputIfFileExists{\jobname.tdosorted}{}
\toggletrue{ownerB}
\togglefalse{ownerdefault}
\section*{Reviewer \#2 Comments}
\sectionbookmark{Reviewer \#2 Comments}
\InputIfFileExists{\jobname.tdosorted}{}
\togglefalse{ownerB}
\makeatletter \@starttoc{tdo}\makeatother % to trigger the creation of the list
\clearpage
\pagenumbering{arabic}
\stR{1st}{reviewer} some text
\stEditor{1st}{editor} some text
\end{document}