2

I’m using the amsart class and the package txfonts in order to using the Times font. I want the titles of the sections, subsections, … with Latin Modern Sans font.

My code is:

\documentclass[a4paper, reqno, 10pt]{amsart}
\usepackage[T1]{fontenc}
\usepackage{txfonts}

\usepackage{lipsum}
% title font
\newcommand*\sectfont{\fontfamily{lmss}\selectfont} 

\begin{document}
    \section{Section 1}
    \lipsum[1]
\end{document}

It doesn’t work and I can’t understand why. I also have tried with sectsty package and LaTeX has given me an error. What is the correct way to change only the type of font (not bold, italic, dimension, …) of the titles with amsart class?

6
  • 1
    Welcome to TeX.SE. You wrote, "I also have tried with sectsty package and LaTeX has give[n] me an error. " What exactly did you try, and what's the error message you got? Please be specific.
    – Mico
    Dec 1, 2021 at 8:46
  • The code you provided does not result in an error if I compile it (after having added some code as the body of the document where I placed the \sectfont macro). Dec 1, 2021 at 10:51
  • The problem is that the code doesn’t return the titles of the sections with the changed font. @JasperHabicht
    – alessandro
    Dec 1, 2021 at 12:24
  • This is the error: Package sectsty Error: The sectsty package doesn't work with(sectsty) this document class. scrartcl, scrbook, and scrreprt.} @Mico
    – alessandro
    Dec 1, 2021 at 12:25
  • @alessandro The code that you posted above does not return anything (except to the log), of course, and compiles without any error. So, as long as you don't provide a minimal (non-)working example that produces the said error, we are virtually unable to help you, even though you told us more about the error you get. We need to know how you set up your section titles etc. and how they are styled. Dec 1, 2021 at 12:38

1 Answer 1

4

The font choice is hardwired the sectional command definitions. And sectsty is not compatible with amsart.

You can patch the commands.

\documentclass[a4paper, reqno, 10pt]{amsart}
\usepackage[T1]{fontenc}
\usepackage{newtxtext,newtxmath}
\usepackage{xpatch}

\renewcommand{\sfdefault}{lmss}

\patchcmd{\part}{\normalfont}{\alessandrofont}{}{}
\patchcmd{\specialsection}{\normalfont}{\alessandrofont}{}{}
\patchcmd{\section}{\normalfont\scshape}{\alessandrofont}{}{}
\patchcmd{\subsection}{\normalfont}{\alessandrofont}{}{}
\patchcmd{\subsubsection}{\normalfont}{\alessandrofont}{}{}
\newcommand{\alessandrofont}{\normalfont\sffamily}

\begin{document}

\section{This is lmss}

\end{document}

enter image description here

Avoid txfonts: the font metrics it uses are bad. Using NewTX is much better.

1
  • Thank you @egreg
    – alessandro
    Dec 1, 2021 at 14:02

You must log in to answer this question.

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