\DeclareUnicodeCharacter{2212}{-}는 LuaLatex 컴파일러에서 작동하지 않습니다.

\DeclareUnicodeCharacter{2212}{-}는 LuaLatex 컴파일러에서 작동하지 않습니다.

나는 내가 사용하는 컴파일러를 전환할 수 있는 뒷면에 있습니다. 저는 포스터 작업을 하고 있는데 LuaLatex를 컴파일러로 사용해야 합니다. 그러나 "\DeclareUnicodeCharacter{2212}{-}" 줄은 "정의되지 않은 제어 시퀀스" 오류를 발생시킵니다.

내 요점을 설명하기 위해 예를 들어 보겠습니다.

\documentclass[pt]{beamer}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage{upgreek}
\usepackage{mathtools}
\usetheme{Berlin}

\DeclareUnicodeCharacter{2212}{-}

\begin{document}
\begin{frame}{Example}
    The equation is
    \begin{equation}
    y=mx+c
    \end{equation}
\end{frame}
\end{document}

"pdfLatex" 컴파일러를 선택하면 제대로 컴파일되지만 "LuaLatex" 컴파일러를 사용하면 컴파일이 중단됩니다. LuaLatex 컴파일러에 사용할 수 있는 대체 줄(\DeclareUnicodeCharacter{2212}{-})이 있습니까? 감사해요.

답변1

pdfLaTeX 또는 LuaLaTeX를 사용하여 문서를 잠재적으로 컴파일할 수 있도록 서문을 수정하는 것이 좋습니다.

\documentclass[pt]{beamer}
\usetheme{Berlin}
\usepackage[brazil]{babel}

\usepackage{iftex} % for '\iftutex' and related conditionals
\iftutex
   \usepackage{fontspec} % optional
\else
   \usepackage[T1]{fontenc}
   %\usepackage[utf8]{inputenc} % 'utf8' is the default nowadays
   \DeclareUnicodeCharacter{2212}{-}
   \usepackage{upgreek}
\fi

\usepackage{mathtools} % no need to load 'amsmath' separately

\begin{document}
\begin{frame}{Example}
    The equation is
    \begin{equation}
    y=mx-c
    \end{equation}
\end{frame}
\end{document}

이 설정을 사용하면 pdfLaTeX를 사용하여 문서를 컴파일하는 경우에만 inputenc및 패키지가 로드됩니다.fontenc

참고: mathtools패키지는 자동으로 로드되므로 별도로 amsmath로드할 필요가 없습니다 amsmath. (그리고 beamer클래스를 사용하면 amsmath기본적으로 패키지가 로드됩니다...)

답변2

newunicodechar모든 엔진에서 패키지를 사용할 수 있습니다 .

\usepackage{newunicodechar}

\newunicodechar{−}{-} % U+2212

그러나 LuaLaTeX 에서 유니코드 입력 unicode-math을 사용하려면 professionalfonts.beamer

관련 정보