Comments (1)
目前我比较满意的解决办法
在进入tabular
之前\let^^M\empty
\protected\gdef\tabulartest{%
\catcode\active\active\let^^M\empty}
\usepackage{etoolbox}
\AtBeginEnvironment{tabular}{\begingroup\tabulartest}
\AfterEndEnvironment{tabular}{\endgroup}
\documentclass{ctexbook}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{ifthen}
\newif\ifteacher
\usepackage{color}
\usepackage{etoolbox}
\makeatletter
\begingroup
\catcode`\^^M\active
\protected\gdef\mathobeylines{%
\catcode`\^^M\active \let^^M\math@obeylines}
\protected\gdef\tabularobeylines{%
\catcode`\^^M\active \let^^M\empty}
\endgroup
\AtBeginEnvironment{tabular}{\begingroup\tabularobeylines}
\AfterEndEnvironment{tabular}{\endgroup}
\protected\def\math@obeylines{%
\unless\ifmmode\expandafter\par\fi}
\newcommand\testE[2]{\item[5.]#1\par#2\par%
\ifteacher\begingroup\mathobeylines\expandafter\testEaux
\else\expandafter\@gobble\fi}
\newcommand\testEaux{\futurelet\nextMacro\wait}
\newcommand\wait[1]{\ifx\nextMacro\math@obeylines\expandafter\testEaux\else \indent\color{red}#1\endgroup\fi}
\makeatother
\begin{document}
\teachertrue
下面内容可以编译之后再看
\def\temp{\textasciicircum\textasciicircum M}
\begin{itemize}
\testE{ID}{由于更改了行结束符号\temp 的catcode,导致tabula环境中使用\string\hline 出错.}
{解:加了数学模式的判断,数学环境不会出错了。
$\begin{cases}
x\geqslant 0\\
x\leqslant y\\
x+y\geqslant 2
\end{cases}$
tabular环境需要在\string\begin\{tabular\}之前将\temp 设置为空\string\let\temp\string\empty.
\string\AtBeginEnvironment\{tabular\}\{\string\begingroup\string\tabularobeylines\}
\string\AfterEndEnvironment\{tabular\}\{\string\endgroup\}
\begin{tabular}{|c|c|c|c|}
\hline
$x$ & $(0$,$\ln (2k))$ & $\ln (2k)$ & $(\ln (2k)$,$k) $\\
\hline
$f'(x)$ & $-$ & $0$ & $+ $\\
\hline
$f(x)$ & ${\searrow}$ & 极小值 & ${\nearrow} $\\
\hline
\end{tabular}
后面可以继续obeylines
别急丽丽
}
\end{itemize}
\end{document}
from forum.
Related Issues (20)
- 讨论范围:CTeX套装问题or中文TeX问题? HOT 6
- Error: Undefined control sequence HOT 17
- 汉字直排行间标点下冒号(及分号)的问题 HOT 4
- xeCJK宏包文档中3.2.1节需要增补 HOT 4
- xeCJKfntef 和 ulem 联用时影响 \textbf 的作用范围 HOT 3
- 使用XeLatex构建中文文档源码时报错: xdvipdfmx:fatal: Unknown coverage format HOT 7
- 如何在article中调整所有caption为楷体 HOT 1
- linux和windows下伪粗效果不统一 HOT 6
- 中英文之间空格不习惯,如何去掉? HOT 11
- CJKfntef 是否具有 xeCJKfntef 的 subtract 功能?
- CTeX 3.0.212.1 xelatex编译通过,但无法生成pdf。dvipdfmx:fatal: typecheck: Invalid object type: -1 7 (line 2378)] HOT 6
- 关于LaTeX2e中文档类使用l3keys键对值的问题 HOT 8
- 当minipage环境和enumerate配合使用时,引入hyperref宏包会导致minipage顶部对齐失效 HOT 2
- 选项 leqno 与 fleqn 的缩写 HOT 13
- 我想将某些内容固定排版在偶数页的页面底部,但使用\ifodd\value{page}进行判断时在某些情形下会失效 HOT 4
- `jiazhu` 宏包是否能实现 `linespread < 1` 的排版效果?
- 如何将附录放在backmatter后同时对附录进行编号? HOT 6
- 能否实现英语句子中自动使用非中文字体的标点符号 HOT 3
- How to draw an specific feynman diagram with TikZ (LaTeX) HOT 4
- [NFSS] 关于使表示字体的控制序列等于\relax的作用(的问题) HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forum.