You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

LibreOffice TexMath中lualatexja-preset的baselineshift参数失效求助

LibreOffice Writer中TexMath的\ltjsetparameter{yjabaselineshift=0pt}参数无效问题

问题描述

使用TexMath结合luatexja-preset在LibreOffice Writer中插入复杂公式文本时,整体功能正常,但\ltjsetparameter{yjabaselineshift=0pt}参数完全无效。相同代码在TexStudio中可生成正确排版效果(日文与拉丁字符、符号基线完全对齐,无上下偏移),但在LibreOffice Writer中运行时,日文字符始终无法与其他字符对齐,调整yjabaselineshift参数值也无任何效果。

可正常运行的TexStudio代码

\documentclass{article}
\usepackage{amsmath,amsthm, amsfonts,amssymb}

\usepackage{mathtools,array,booktabs} 
\usepackage[noto,fontspec,match]{luatexja-preset}
\usepackage{cancel}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}
\usepackage[]{mdframed}
\usepackage[sfdefault]{noto}
\ltjsetparameter{yjabaselineshift=0pt}
\renewcommand*\familydefault{\sfdefault}

\usepackage{fontspec}
\usepackage{lualatex-math}

\begin{document}
    \sffamily
    \begin{equation*}
        \tcboxmath[size=small, colback=white, sharp corners=all]{
            \text{い-adj(\sim}\cancel{\text{い}})\to\text{\sim}\text{さ}\\ 
        } 
    \end{equation*}
\end{document}

解决方案

方案1:在公式内手动调整日文基线

绕过全局参数失效的问题,在每个包含日文的\text命令中,使用\raisebox手动微调基线偏移,数值可根据实际对齐效果调整:

\tcboxmath[size=small, colback=white, sharp corners=all]{
    \text{\raisebox{-0.5pt}{い}-adj(\sim}\cancel{\text{\raisebox{-0.5pt}{い}}})\to\text{\sim\text{\raisebox{-0.5pt}{さ}}}\\ 
}

方案2:在公式环境内嵌入参数设置

由于LibreOffice的TexMath可能未正确加载文档预导言中的全局设置,将\ltjsetparameter直接放在公式环境内部,强制参数生效:

\begin{equation*}
    \ltjsetparameter{yjabaselineshift=0pt}
    \tcboxmath[size=small, colback=white, sharp corners=all]{
        \text{い-adj(\sim}\cancel{\text{い}})\to\text{\sim}\text{さ}\\ 
    } 
\end{equation*}

方案3:配置TexMath的默认预导言

打开LibreOffice的TexMath设置,找到「预导言」编辑项,将luatexja相关配置添加到默认预导言中,确保编译时加载完整参数:

\usepackage[noto,fontspec,match]{luatexja-preset}
\ltjsetparameter{yjabaselineshift=0pt}
\usepackage[sfdefault]{noto}
\renewcommand*\familydefault{\sfdefault}

同时确认TexMath的编译命令设置为lualatex,而非其他LaTeX编译器。

内容的提问来源于stack exchange,提问作者Ben Engbers

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 18:22:28