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

M1 Mac下RMarkdown遇重音字符停止生成.tex文件问题求助

解决M1 Mac上RMarkdown含重音字符编译LaTeX崩溃的问题

核心问题定位

你遇到的崩溃源于XeLaTeX与inputenc包的冲突:XeLaTeX原生支持UTF-8编码,inputenc是为PDFLaTeX设计的编码适配包,同时加载会导致编码解析逻辑冲突,触发紧急停止错误。

分步解决方案

  • 移除冲突的LaTeX包引用
    删除YAML前端中header-includes内的\usepackage[utf8]{inputenc},修改后的YAML示例:

    output:
      pdf_document: 
        latex_engine: xelatex
        toc: true
        extra_dependencies: ["float"]
      html_document:
        df_print: paged
      word_document: default
    always_allow_html: true
    editor_options: 
      markdown: 
        wrap: sentence
    encoding: UTF-8
    
  • 添加字体支持(可选但推荐)
    为确保重音字符渲染正常,可通过fontspec指定支持拉丁重音的系统字体,在header-includes中补充:

    header-includes:
      - \usepackage{fontspec}
      - \setmainfont{Latin Modern Roman} # 或苹果系统自带的「San Francisco」「Times New Roman」
    
  • 确认文件编码
    在RStudio中通过File > Save with Encoding...选择「UTF-8」保存文档,确保文件本身编码无异常。

  • 重置适配M1架构的TinyTeX
    若之前安装的TinyTeX是x86版本,在M1芯片上可能存在兼容性问题,执行以下代码重装适配版本:

    tinytex::uninstall_tinytex()
    tinytex::install_tinytex()
    

内容的提问来源于stack exchange,提问作者Manuel Modroño

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 05:32:05