diff --git a/TeXmacs/plugins/latex/progs/convert/latex/tmtex.scm b/TeXmacs/plugins/latex/progs/convert/latex/tmtex.scm index f96afe4b9c..d39622f709 100644 --- a/TeXmacs/plugins/latex/progs/convert/latex/tmtex.scm +++ b/TeXmacs/plugins/latex/progs/convert/latex/tmtex.scm @@ -1588,10 +1588,10 @@ (define (tmtex-decode-color s . force-html) (with cm (if (string-starts? s "#") "HTML" (named-color->xcolormap s)) - (cond ((and (== cm "none") (nnull? force-html)) + (cond ((== cm "HTML") + (string-append "#" (html-color->latex-xcolor s))) + ((and (== cm "none") (nnull? force-html)) (tmtex-decode-color (get-hex-color s) force-html)) - ((and (== cm "HTML") (nnull? force-html)) - `((!option "HTML") ,(html-color->latex-xcolor s))) ((== cm "texmacs") (when (nin? s tmtex-colors) (set! tmtex-colors (append (list s) tmtex-colors))) @@ -1607,7 +1607,7 @@ (define (tmtex-make-color val arg) (with ltxcolor (tmtex-decode-color val #t) (if (list? ltxcolor) - `(!group (!append (color ,@ltxcolor) ,arg)) + `(!group (!append (color ,@ltxcolor) (!group ,arg))) `(tmcolor ,ltxcolor ,arg)))) (define (post-process-math-text t) diff --git a/TeXmacs/progs/convert/latex/tmtex.scm b/TeXmacs/progs/convert/latex/tmtex.scm index 710626990e..f9ec2cf5ed 100644 --- a/TeXmacs/progs/convert/latex/tmtex.scm +++ b/TeXmacs/progs/convert/latex/tmtex.scm @@ -1588,10 +1588,10 @@ (define (tmtex-decode-color s . force-html) (with cm (if (string-starts? s "#") "HTML" (named-color->xcolormap s)) - (cond ((and (== cm "none") (nnull? force-html)) + (cond ((== cm "HTML") + (string-append "#" (html-color->latex-xcolor s))) + ((and (== cm "none") (nnull? force-html)) (tmtex-decode-color (get-hex-color s) force-html)) - ((and (== cm "HTML") (nnull? force-html)) - `((!option "HTML") ,(html-color->latex-xcolor s))) ((== cm "texmacs") (when (nin? s tmtex-colors) (set! tmtex-colors (append (list s) tmtex-colors))) @@ -1607,7 +1607,7 @@ (define (tmtex-make-color val arg) (with ltxcolor (tmtex-decode-color val #t) (if (list? ltxcolor) - `(!group (!append (color ,@ltxcolor) ,arg)) + `(!group (!append (color ,@ltxcolor) (!group ,arg))) `(tmcolor ,ltxcolor ,arg)))) (define (post-process-math-text t) diff --git a/TeXmacs/tests/tmu/201_100.tmu b/TeXmacs/tests/tmu/201_100.tmu new file mode 100644 index 0000000000..876dd4b8fd --- /dev/null +++ b/TeXmacs/tests/tmu/201_100.tmu @@ -0,0 +1,40 @@ +> + +> + +<\body> + <\equation*> + d d d + + + <\equation*> + d d d + + + <\equation*> + d d d + + + \; + + \; + + \\[ {\\color{red}{d d d}} d d d \\] + + \\[ {\\color[HTML]{AA6666}d d d} d d d \\] + + \\[ {\\color{blue}{d d d}} d d d \\] + + \; + + \; + + \; + + +<\initial> + <\collection> + + + + diff --git a/devel/201_100.md b/devel/201_100.md new file mode 100644 index 0000000000..4e3ce85e79 --- /dev/null +++ b/devel/201_100.md @@ -0,0 +1,19 @@ +# [201_100] 公式带前景色时,使用部分颜色时导出 LaTex 代码会出错 + +## 如何测试 + +测试文件 `/mogan/TeXmacs/tests/tmu/201_100.tmu ` +原本复制到 LaTeX 效果 +``` +\[ {\color{red}{d d d}} d d d \] +\[ {\color[HTML]{AA6666}d d d} d d d \] +\[ {\color{blue}{d d d}} d d d \] +``` + +预期的正确效果 +复制到 LaTeX 效果 +``` +\[ {\color{red}{d d d}} d d d \] +\[ {\color{#AA6666}{d d d}} d d d \] +\[ {\color{blue}{d d d}} d d d \] +```