handle commands from xargs.sty correctly

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37289 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2011-01-21 21:21:58 +00:00
parent 3d4f76cf2d
commit 85d2c53532
3 changed files with 53 additions and 13 deletions

View File

@ -394,6 +394,10 @@ $$
\chapter*{}
\chaptername
\check{}
\CheckCommand{}[][]{}
\CheckCommand*{}[][]{}
\CheckCommandx{}[][]{} % xargs.sty
\CheckCommandx*{}[][]{} % xargs.sty
%\circle{} % picture environment (JMarc)
%\circle*{}
\cleardoublepage
@ -410,6 +414,10 @@ $$
\dblfigrule
\dblfloatpagefraction
\dbltopfraction
\DeclareRobustCommand{}[][]{}
\DeclareRobustCommand*{}[][]{}
\DeclareRobustCommandx{}[][]{} % xargs.sty
\DeclareRobustCommandx*{}[][]{} % xargs.sty
\def{}{}
\definecolor{}{}{,,}
\DeleteShortVerb{} % from doc.sty, argument must be verbatim
@ -507,11 +515,13 @@ $$
\newboolean{}
\newcommand{}[][]{}
\newcommand*{}[][]{}
%\newcommand{}[]{} % tex2lyx can support this when the file format is the one of LyX 1.6.x
\newcommandx{}[][]{} % xargs.sty
\newcommandx{}[][]{} % xargs.sty
\newcounter{}[]
\newenvironment{}[][]{}{}
\newenvironment*{}[][]{}{}
%\newenvironment{}[]{}{} % tex2lyx can support this when the file format is the one of LyX 1.6.x
\newenvironmentx{}[][]{}{} % xargs.sty
\newenvironmentx*{}[][]{}{} % xargs.sty
\newfont{}{ scaled }
\newlength{}
\newpage
@ -553,6 +563,8 @@ $$
\protect
\providecommand{}[][]{}
\providecommand*{}[][]{}
\providecommandx{}[][]{} % xargs.sty
\providecommandx*{}[][]{} % xargs.sty
\ps
\psfrag{}[][][][]{translate}
\psfrag*{}[][][][]{translate}
@ -570,10 +582,13 @@ $$
\refstepcounter{}
\renewcommand{}[][]{}
\renewcommand*{}[][]{}
%\renewcommand{}[]{} % tex2lyx can support this when the file format is the one of LyX 1.6.x
\renewcommandx{}[][]{} % xargs.sty
\renewcommandx{}[][]{} % xargs.sty
\renewenvironment{}[][]{}{}
\renewenvironment*{}[][]{}{}
%\renewenvironment{}[]{}{}
\renewenvironmentx{}[][]{}{} % xargs.sty
\renewenvironmentx*{}[][]{}{} % xargs.sty
\resizebox{}{}{translate}
\resizebox*{}{}{translate}
\reversemarginpar

View File

@ -24,6 +24,7 @@
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{xargs}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
@ -244,13 +245,27 @@ global def \global\def\macrob#1{b #1 b}
long def \long\def\macroc#1{c #1 c}
global long def \global\long\def\macrod#1{d #1 d}
providecommand \providecommand{\macroe}[1]{e #1 e}
newcommand \newcommand{\macrof}[1]{f #1 f}
renewcommand \renewcommand{\macrof}[1]{g #1 g}
newcommand* \newcommand*{\macroh}[1]{h #1 h}
renewcommand* \renewcommand*{\macroh}[1]{i #1 i}
providecommand* \providecommand*{\macrof}[1]{f #1 f}
newcommand \newcommand{\macrog}[1]{g #1 g}
renewcommand \renewcommand{\macrog}[1]{h #1 h}
newcommand* \newcommand*{\macroi}[1]{i #1 i}
renewcommand* \renewcommand*{\macroi}[1]{j #1 j}
providecommandx \providecommandx{\macrok}[1]{k #1 k}
providecommandx* \providecommandx*{\macrok}[1]{l #1 l}
newcommandx \newcommandx{\macrom}[1]{m #1 m}
renewcommandx \renewcommandx{\macrom}[1]{n #1 n}
newcommandx* \newcommandx*{\macroo}[1]{o #1 o}
renewcommandx* \renewcommandx*{\macroo}[1]{p #1 p}
DeclareRobustCommand \DeclareRobustCommand{\macroq}[1]{q #1 q}
DeclareRobustCommand* \DeclareRobustCommand*{\macror}[1]{r #1 r}
DeclareRobustCommandx \DeclareRobustCommandx{\macros}[1]{s #1 s}
DeclareRobustCommandx* \DeclareRobustCommandx*{\macrot}[1]{t #1 t}
Now use them all:
\macroa{x} \macrob{x} \macroc{x} \macrod{x} \macroe{x} \macrof{x} \macroh{x}
\macroa{x} \macrob{x} \macroc{x} \macrod{x} \macroe{x} \macrof{x} \macrog{x}
\macroi{x} \macrok{x} \macrom{x} \macroo{x} \macroq{x} \macror{x}
The following tow don't work, but they should???
%\macros{x} \macrot{x}
\section{Special formattings\index{Special formattings}}

View File

@ -2965,11 +2965,18 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
skip_spaces_braces(p);
}
else if (t.cs() == "newcommand" ||
else if (t.cs() == "DeclareRobustCommand" ||
t.cs() == "DeclareRobustCommandx" ||
t.cs() == "newcommand" ||
t.cs() == "newcommandx" ||
t.cs() == "providecommand" ||
t.cs() == "renewcommand") {
// providecommand could be handled by parse_command(),
// but we need to call add_known_command() here.
t.cs() == "providecommandx" ||
t.cs() == "renewcommand" ||
t.cs() == "renewcommandx") {
// DeclareRobustCommand, DeclareRobustCommandx,
// providecommand and providecommandx could be handled
// by parse_command(), but we need to call
// add_known_command() here.
string name = t.asInput();
if (p.next_token().asInput() == "*") {
// Starred form. Eat '*'
@ -2984,7 +2991,10 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
opt1 + opt2 +
'{' + p.verbatim_item() + '}';
if (t.cs() == "providecommand" ||
if (t.cs() == "DeclareRobustCommand" ||
t.cs() == "DeclareRobustCommandx" ||
t.cs() == "providecommand" ||
t.cs() == "providecommandx" ||
name[name.length()-1] == '*')
handle_ert(os, ert, context);
else {