我使用最新版本的 MacTex 和 Lualatex 排版创建了一本书。(\documentclass[a4paper,11pt,twoside]{book}
)我已经测试了\reflectbox
整个文档并且始终运行良好,但是,当我想使用命令翻转符号时,我通过以下方式将其包含在目录中
\addtocontents{toc}{~\noindent\hfil\reflectbox{\fontsize{20pt}{20pt}{\fryingpan}} \hspace{2pt} {\textbf{\large{Recipes}}} \hspace{2pt} {\fontsize{20pt}{20pt}{\fryingpan}}\hfil\par}
我得到 Tex:661:未定义的控制序列。
我也尝试过添加更多括号,例如
\addtocontents{toc}{~\noindent\hfil{\reflectbox{\fontsize{20pt}{20pt}{\fryingpan}}} \hspace{2pt} {\textbf{\large{Recipes}}} \hspace{2pt} {\fontsize{20pt}{20pt}{\fryingpan}}\hfil\par}
但最终却出现相同的错误。
如果没有\reflectbox
,代码也可以正常工作:
\addtocontents{toc}{~\noindent\hfil{\fontsize{20pt}{20pt}{\fryingpan}} \hspace{2pt} {\textbf{\large{Recipes}}} \hspace{2pt} {\fontsize{20pt}{20pt}{\fryingpan}}\hfil\par}
有什么想法吗?詹姆斯
这是我的序言:
\documentclass[a4paper,11pt,twoside]{book}
\renewcommand{\baselinestretch}{1}
\usepackage[no-math]{luatexja-fontspec}
\setmainjfont{Hiragino Mincho Pro}
\setsansjfont{Hiragino Sans}
\setmainfont[Ligatures=TeX]{CMU Serif}
\setsansfont[Ligatures=TeX]{Linux Biolinum O}
\ltjsetparameter{jacharrange={-1, -2, +3, -4, -5, +6, +7, +8}}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage{russian}
\setotherlanguage{japanese}
\setlength{\columnsep}{3em}
\setlength{\columnseprule}{0.5pt}
%\setlength{\footnotesep}{0.3cm}
\setlength{\skip\footins}{18pt}
\usepackage [top=1.8cm,
bottom=1.8cm,
left=3cm,
right=2cm,
headheight=17pt,
includehead,includefoot,
%heightrounded,
%showframe
]{geometry}
\usepackage{multicol}
\usepackage{parskip}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
\usepackage{verbatim}
\usepackage{graphicx}
\setlength{\intextsep}{18pt}
\setlength{\textfloatsep}{\baselineskip}
\setlength{\floatsep}{\baselineskip}
\usepackage[export]{adjustbox}
\usepackage{rotating}
\usepackage{fancyhdr}
\usepackage{float}
\usepackage{wrapfig}
%\usepackage{subcaption}
\usepackage{caption}
\captionsetup[figure]{aboveskip=7pt, belowskip=- \baselineskip,font=footnotesize,labelfont=bf}
\usepackage{enumitem}
\setlist[itemize]{parsep=4pt}
\setlist[enumerate]{parsep=5pt}
\usepackage{gensymb}
%\usepackage{wrapfig}
\usepackage{natbib}
\usepackage{array,tabu}
\usepackage{amssymb, pifont, marvosym, tikzsymbols, fdsymbol, wasysym, fontawesome, ifsym, academicons}
\usepackage{setspace}
\usepackage{xcolor}
\definecolor{orcid}{HTML}{a7cc46}
\definecolor{RG}{HTML}{21cbbb}
\definecolor{linkedin}{HTML}{1078b3}
\definecolor{twitter}{HTML}{2aa3ef}
\definecolor{face}{HTML}{4469b0}
\usepackage{skak}
\usepackage{chngcntr}
\usepackage{textcomp}
\usepackage{titlesec}
\usepackage{longtable}
%\usepackage{amsmath}
%\usepackage{svg}
\usepackage{nicefrac}
\usepackage{balance}
\usepackage{mdwlist}
\usepackage{imakeidx}
%\usepackage[font=normalsize]{idxlayout}
\usepackage[final]{pdfpages}
\makeindex[columns=2, columnseprule, title=Index]
\PassOptionsToPackage{hyphens}{url}\usepackage[breaklinks,hidelinks,linktocpage=true]{hyperref}
\hypersetup{%
colorlinks = true,
linkcolor = blue,
urlcolor = blue
}
\setlistdepth{4}
\newlist{myEnumerate}{enumerate}{4}
\setlist[enumerate,1]{label=\textit{\arabic*.}}
\setlist[enumerate,2]{label=\textit{\alph*.}}
\setlist[enumerate,3]{label=\textit{\roman*.}}
\setlist[enumerate,4]{label=$$}
\titleformat{\chapter}[block]{\color{black}\Large\bfseries\filcenter}{}{0pt}{}
\titlespacing*{\chapter}{0pt}{0pt}{0pt}
\titleformat{\section}[block]{\color{black}\Large\bfseries\filcenter}{}{1em}{}
\setcounter{secnumdepth}{0}
\setcounter{tocdepth}{3} %definition of the no. of levels in the ToC list
\renewcommand{\thefootnote}{\scriptsize{\roman{footnote}}} %fontsize footnote
\addto\captionsenglish{\renewcommand{\contentsname}{Table of Contents \label{TaoCo}}} %Title of ToC
%definition of \quote margins
\renewenvironment{quote}{%
\list{}{%
\leftmargin20pt % this is the adjusting screw
\rightmargin\leftmargin
}
\item\relax
}
{\endlist}
%--------------------------PAGESTYLE Preface-----------------------------------------
\fancypagestyle{preface}{
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhead[L]{\small Preface}
\fancyhead[R]{\small Name}
\fancyfoot[C]{\small Name}
%\fancyfoot[LE,RO]{\small \thepage}
}
答案1
如果您要经常使用这个反射煎锅,我建议为它编写一个宏:
\newcommand\napgniyrf{\protect\reflectbox{\fontsize{20pt}{20pt}{\fryingpan}}}
请注意\protect
上面评论中建议的。通过此更改,您的 MWE(或至少您的 MWE 应该是这样的!:) 可以正常工作以生成:
完整代码如下:
\documentclass{article}
\usepackage{tikzsymbols}
\usepackage{graphicx}
\newcommand\napgniyrf{\protect\reflectbox{\fontsize{20pt}{20pt}{\fryingpan}}}
\begin{document}
\addtocontents{toc}{~\noindent\hfil{\fontsize{20pt}{20pt}{\fryingpan}}\hspace{2pt}{\textbf{\large{Recipes}}}\hspace{2pt}{\fontsize{20pt}{20pt}{\fryingpan}}\hfil\par}
\addtocontents{toc}{~\noindent\hfil\napgniyrf\hspace{2pt}{\textbf{\large{Recipes}}}\hspace{2pt}{\napgniyrf}\hfil\par}
\tableofcontents
\end{document}
你可能还想定义
\newcommand\Fryingpan{\fontsize{20pt}{20pt}{\fryingpan}}
这样您无需\fontsize
在每次想要使用时都使用\fryingpan
。
答案2
的论点\addtocontents
是移动的,因此脆弱的命令\reflectbox
应该受到保护。相反,定义一个强大的命令更容易。
我会避免\fontsize{20pt}{20pt}
这种情况:\scalebox
更好。
\documentclass{article}
\usepackage{tikzsymbols}
\usepackage{graphicx}
\DeclareRobustCommand\mnapgniyrf{\scalebox{-2}[2]{\fryingpan}}
\DeclareRobustCommand\mfryingpan{\scalebox{2}{\fryingpan}}
\begin{document}
\addtocontents{toc}{%
\noindent\hfil\mfryingpan
\hspace{2pt}\textbf{\large{Recipes}}\hspace{2pt}%
\mnapgniyrf\par
}
\tableofcontents
\end{document}
如果您需要使用不同大小的符号,则可以使用不同的策略
\DeclareRobustCommand\mnapgniyrf[1]{\scalebox{-#1}[#1]{\fryingpan}}
\DeclareRobustCommand\mfryingpan[1]{\scalebox{#1}{\fryingpan}}
而获取双倍大小的调用将是
\mfryingpan{2}
\mnapgniyrf{2}