如何tcolorbox实现中文正确换行

发布于 2024-04-01 21:13:33

代码


\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\usepackage{fontspec}
% 设置边框样式
\tcbset{
    mybox/.style={
        %enhanced,
        colback=white, % 背景色
        colframe=black, % 边框色
        sharp corners, % 锐角
        boxrule=1pt, % 边框宽度
        toprule=1pt, % 顶部边框宽度
        bottomrule=1pt, % 底部边框宽度
        breakable, % 可断行
        height fixed for=all, % 高度与内容长度相同
        before=\par
    }
}
\setmainfont{SimSun}
\newfontfamily\heiti{SimHei}

\begin{document}
\section*{{\heiti 二、立项依据}}
\begin{tcolorbox}[mybox,width=\textwidth]


以瑞典著名光谱学家里德堡 (J. R. Rydberg)名字命名的里德堡原子,是指最外层价电子跃迁到主量子数$n$很大的一类高激发态原子,其轨道半径($\propto n^2$,可达百微米量级)、电偶极矩($\propto n^2$)、




    \includegraphics[width=\linewidth]{example-image} % 示例图片
    \lipsum[4-6] % 示例中文内容
\end{tcolorbox}

\end{document}

输出
QQ截图20240401210651.png

查看更多

关注者
0
被浏览
215
1 个回答
Swit
Swit 2024-04-02
LaTeX nubility!

使用 ctex 宏包或者 xeCJK 宏包,不要直接用 fontspec 调用中文字体。

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览