3

Today,I design a paper cover,some English word need to use the typeface of "Times New Roman" while other English sentence need to use other typeface.

My trial

\documentclass[a4paper,UTF8,winfont]{ctexart}
\usepackage[top=2.8cm, bottom=2.5cm, left=1cm, right=1cm]{geometry}
\usepackage{setspace}
\usepackage{amsmath}
\usepackage{times}
\usepackage{mathptmx}
\begin{document}
 \title{Simulation of a SCARA robot with PD and learning controllers}
 \section{PD controller}
\end{document}

However,the \usepackage{times} apply all english sentence to the typeface of "Times New Roman".Here,I encounted a problem,but I don't know how to solve it?Cab some help me?Thanks sincerely!

abc
  • 291
  • 1
    If Times Roman (or Times New Roman) is supposed to be used for certain words, which other font(s) are supposed to be using? Separately, are you required to use the pdfLaTeX format, or could you use either XeLaTeX or LuaLaTeX? – Mico Jan 11 '14 at 07:11
  • 1
    @Mico,Yes,I use the pdfLaTeX format to compile.other english sentence use the typeface of Trebuchet MS or Vijaya – abc Jan 11 '14 at 07:18
  • @karlkoeller - While its true that the older question also deals with fonts selections applying to small portions of the document, I'd say the new question here adds an important wrinkle: How to make a specific font kick in only for sectioning headers only. – Mico Jan 11 '14 at 08:15
  • @Mico Why do you think the OP wants it to kick in only for section headings? The question just says for some English word(s?) but not other English sentences. – cfr Jan 11 '14 at 22:33
  • @cfr - It was admittedly a bit of a guess. Actually, given the fairly minimal nature of the OP's MWE, it was just about the only guess left... – Mico Jan 11 '14 at 22:57
  • @tangshutao It is pretty easy to do this using pdflatex as well. I actually wrote an answer but can't post it because the question is closed. What I did was use the commands from ctexart to change the formatting of the section headings. I also created \timesstyle and \texttm{} for switching to Times elsewhere should you need to. This avoids possible conflicts between ctex and sectsty. I was also going to show how to do the same thing (using ctex's facilities) with xelatex since the package seems to be set up for that. However, I'm not sure how much use this comment will be without the answer! – cfr Jan 11 '14 at 23:52

1 Answers1

4

If you're willing and able to switch from pdfLaTeX to either XeLaTeX or LuaLaTeX, it's straightforward to make LaTeX use one font family (e.g., Times New Roman) for sectioning headers and another font family (e.g., Trebuchet MS) for all other text. The example below uses the packages fontspec and sectsty to accomplish this, and it needs to be compiled under either XeLaTeX or LuaLaTeX.

enter image description here

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Trebuchet MS}
\newfontfamily\otherfont{Times New Roman}

\usepackage{sectsty}
\allsectionsfont{\otherfont}

\title{\otherfont My title}
\author{\otherfont A. U. Thor}
\date{}

\begin{document}
\maketitle
\section{Here we go}
\subsection{and on and on and on}
And here's some random text.
\end{document}
Mico
  • 506,678