关于这个问题如何创建虚拟通用环境替代品?我学会了如何用虚拟环境替换通用环境。到目前为止,我已经成功地用 替换了包\currenttime
中的环境。datetime
\def\currenttime{Current Time}
但是当我尝试这个策略时\includegraphics
:
\documentclass[10pt,a5paper,twoside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage[showframe,pass]{geometry}
\newif\ifdebug
\debugtrue
% \debugfalse
\ifdebug
% \def\includegraphics{includegraphics}
\newcommand{\includegraphics}{includegraphics}
\else\fi
\begin{document}
\includegraphics[width=\linewidth]{pictures/ex01}
\end{document}
它不起作用:
! Missing number, treated as zero.
<to be read again>
]
l.86 \includegraphics[width=\linewidth]
{pictures/ex01}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Illegal unit of measure (pt inserted).
<to be read again>
]
l.86 \includegraphics[width=\linewidth]
{pictures/ex01}
Dimensions can be in units of em, ex, in, pt, pc,
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!
I'll assume that you meant to say pt, for printer's points.
To recover gracefully from this error, it's best to
delete the erroneous units; e.g., type `2' to delete
two letters. (See Chapter 27 of The TeXbook.)
\includegraphics[width=\linewidth]{pictures/ex01}
我可以像在环境中一样将命令内容包装为逐字环境吗?
\@ifundefined{longtable}
{
\newenvironment{longtable}[0]
{longtable environment \par\verbatim\tiny}
{\endverbatim\endgraf\normalfont replacement for debug mode}
}{}
更新
尝试做:
\newcommand{\includegraphics}[2]{\par\verbatim\tiny includegraphics #1 #2 \endverbatim\endgraf\normalfont}
引发一个新错误:
File: t1cmtt.fd 2014/09/29 v2.5h Standard LaTeX font definitions
)
Runaway argument?
! Paragraph ended before \next was complete.
<to be read again>
\par
l.87
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.
但它在 PDF 上打印了一些内容:
有关的:
答案1
像这样的事情??
\documentclass[10pt,a5paper,twoside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%\usepackage[brazil]{babel}
\usepackage[showframe,pass]{geometry}
\usepackage{graphicx}
\newif\ifdebug
\debugtrue
% \debugfalse
\ifdebug
\renewcommand{\includegraphics}[2][]{\detokenize{\includegraphics[#1]{#2}}}
\else\fi
\begin{document}
\sloppy% can be used to avoid overfull boxes
\includegraphics[width=\linewidth]{pictures/ex01}
\includegraphics[width=\linewidth]{pictures/long-directory-name/ex01}
\end{document}
答案2
看起来像一份工作xparse
;-)
\documentclass[10pt,a5paper,twoside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage[showframe,pass]{geometry}
\usepackage{xparse}
\usepackage{graphicx}
\newif\ifdebug
\debugtrue
% \debugfalse
\ifdebug
\RenewDocumentCommand\includegraphics{s+O{}om}{includegraphics}
\else\fi
\begin{document}
\includegraphics[width=\linewidth]{pictures/ex01}
\end{document}