3

Given,

\documentclass{article}

\usepackage{times}

\begin{document}
    This is textual typewriter {\tt Angry Hyena kills Lion to save her baby}
    
    This is mathematical typewriter ${\tt Angry~Hyena~kills~Lion~to~save~her~baby}$
    
    
\end{document}

one may notice that the styles for the typewriter fonts are quite different. What I am looking for is to change the textual style to the other. So, when I uses {\tt ...}, I get the style for ${\tt ...}$.

1
  • 1
    don't use times (it is a very old package) use a more modern times clone with a matching font set eg \usepackage{newtxtext,newtxmath} also don't use \tt it has not been defined by default in latex since 1993, use \texttt{abc} in text and \mathtt{abc} in math Commented Jul 20, 2021 at 19:31

2 Answers 2

3

Restore the default computer modern tt font with \renewcommand{\ttdefault}{cmtt}. Note also, \texttt{} is the preferred invocation syntax for LaTeX in text mode and \mathtt{} in math mode.

\documentclass{article}

\usepackage{times}

\renewcommand{\ttdefault}{cmtt}

\begin{document}
    This is textual typewriter \texttt{Angry Hyena kills Lion to save her baby}
    
    This is mathematical typewriter $\mathtt{%
      Angry~Hyena~kills~Lion~to~save~her~baby}$
    
    
\end{document}

enter image description here

2

The executable code of the times package consists of just a few lines:

\ProvidesPackage{times}%
[2020/03/25 PSNFSS-v9.3
(SPQR)
]
\renewcommand{\sfdefault}{phv} % Helvetica clone
\renewcommand{\rmdefault}{ptm} % Times Roman clone
\renewcommand{\ttdefault}{pcr} % Courier clone
\endinput

If all you want to do is change the roman (serif) font to a Times Roman clone, you shouldn't execute \usepackage{times}. Instead, just execute

\renewcommand{\rmdefault}{ptm}

A small MWE (minimum working example):

enter image description here

\documentclass{article}
\renewcommand{\rmdefault}{ptm}
\newcommand\HW{Hello, World}
\begin{document}
\obeylines %just for this example
\HW. \textit{\HW}. 
\textbf{\HW}. \textbf{\textit{\HW}}. 
\textsc{\HW}. \textbf{\textsc{\HW}}.
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .