如何在 acm-small 中使用替代字体

如何在 acm-small 中使用替代字体

我正在写一篇英文论文,我使用 acm-small latex 版本的标准来生成文件。我使用了默认提供的 acmsmall-sample.tex 并对其进行了编辑以生成我的 pdf。

但是,现在我想在文档中使用一些 Hindi 语言单词。我了解到可以使用包fontspec和 XeLatex 来实现这一点,我可以使用设置新的字体系列\newfontfamily。但问题是,一旦我使用fontspec包和\newfontfamily设置 Hindi 字体并编译 .tex 文件,获得的 .pdf 中的英文单词的字体样式就会发生变化(现在的单词字体更浅了)。

如果有人能就此问题的任何修复或解决方法提出建议,我将不胜感激。提前致谢。

答案1

fontspec加载 Latin Modern 字体,而不是经典的 Computer Modern。要恢复它,请尝试

\usepackage[OT1]{fontenc}
\renewcommand\rmdefault{cmr}
\renewcommand\sfdefault{cmss}
\renewcommand\ttdefault{cmtt}

然而,字体编码可能OT1与您的印地语字体不兼容。

答案2

您实际上无法acmsmall使用 XeLaTeX 或 LuaLaTeX 编译文档fontspec。如果您只有几个单词,您可以执行以下操作。

准备一个包含以下单词的文件

输入一个名为hindiwords.tex

\documentclass[multi=varwidth]{standalone}
\usepackage{varwidth}
\usepackage{fontspec}
\setmainfont{Devanagari MT} % choose the one you prefer

\begin{document}

\begin{varwidth}{20cm}% sun
\strut
रवि
\end{varwidth}

\begin{varwidth}{20cm}% moon
\strut
चांद
\end{varwidth}

\begin{varwidth}{20cm}% earth
\strut
पृथ्वी
\end{varwidth}

\end{document}

现在我们知道这个单词对应的页面了(几个单词就可以轻松管理了。

编译 word 文件

xelatex hindiwords.tex

acmsmall准备课程文件

\documentclass[prodmode,acmtecs]{acmsmall}

\usepackage{graphicx}

% set up the number correspondences
\newcommand\hindiwordsun{1}
\newcommand\hindiwordmoon{2}
\newcommand\hindiwordearth{3}

% the command for using them
\DeclareRobustCommand{\hindiword}[1]{%
  \raisebox{-\dp\strutbox}{%
    \includegraphics[page=\csname hindiword#1\endcsname]{hindiwords}%
  }%
}


% Metadata Information
\acmVolume{9}
\acmNumber{4}
\acmArticle{39}
\acmYear{2010}
\acmMonth{3}

% Copyright
\setcopyright{rightsretained}

% DOI
\doi{0000001.0000001}

%ISSN
\issn{1234-56789}

% Document starts
\begin{document}

% Page heads
\markboth{A. Uthor}{About inserting Hindi words in ACM documents}

% Title portion
\title{About inserting Hindi words in ACM documents}
\author{A. Uthor
\affil{\TeX.Stackexchange}}

\begin{abstract}
I want to use Hindi words in ACM class documents.
\end{abstract}

%
% The code below should be generated by the tool at
% http://dl.acm.org/ccs.cfm
% Please copy and paste the code instead of the example below. 
%
\begin{CCSXML}
<ccs2012>
 <concept>
  <concept_id>10010520.10010553.10010562</concept_id>
  <concept_desc>Computer systems organization~Embedded systems</concept_desc>
  <concept_significance>500</concept_significance>
 </concept>
 <concept>
  <concept_id>10010520.10010575.10010755</concept_id>
  <concept_desc>Computer systems organization~Redundancy</concept_desc>
  <concept_significance>300</concept_significance>
 </concept>
 <concept>
  <concept_id>10010520.10010553.10010554</concept_id>
  <concept_desc>Computer systems organization~Robotics</concept_desc>
  <concept_significance>100</concept_significance>
 </concept>
 <concept>
  <concept_id>10003033.10003083.10003095</concept_id>
  <concept_desc>Networks~Network reliability</concept_desc>
  <concept_significance>100</concept_significance>
 </concept>
</ccs2012>  
\end{CCSXML}

\ccsdesc[500]{Computer systems organization~Embedded systems}
\ccsdesc[300]{Computer systems organization~Redundancy}
\ccsdesc{Computer systems organization~Robotics}
\ccsdesc[100]{Networks~Network reliability}

%
% End generated code
%

\terms{Design, Algorithms, Performance}

\keywords{Wireless sensor networks, media access control,
multi-channel, radio interference, time synchronization}

\acmformat{A. Uthor, 2016. About inserting Hindi words in ACM documents}

\begin{bottomstuff}
This work is supported by the National Science Foundation, under
grant CNS-0435060, grant CCR-0325197 and grant EN-CS-0329609.

Author's addresses: A. Uthor, \TeX.Stackexchange
\end{bottomstuff}

\maketitle


\section{Introduction}

The word for sun is \hindiword{sun}; the word for moon is \hindiword{moon}
and the word for earth is \hindiword{earth}

% History dates
\received{October 2016}{September 2016}{June 2016}

\end{document}

(我修改了该sample1.tex文件。)

处理主要文件

运行 LaTeX 后(以正常方式),你将获得

在此处输入图片描述

更高分辨率

在此处输入图片描述

相关内容