(EDIT 1: In an earlier version of this answer, I said to use 'OT1' as the option to fontenc; I now think you can use T1 or OT1; you just need to put the packages in the right order...)
Apparently you need to load the packages in a certain order.
The following works for me (– I don't have Iosevka installed right now so I substituted Cousine –):
\documentclass{article}
\usepackage{fontspec}
\usepackage[T1]{fontenc}
\usepackage{mlmodern}
\begin{document}
This should be in MLModern's roman font.
\texttt{This should be in MLModern's teletype font.}
\setmonofont{Cousine}
\texttt{This should be in Cousine.}
\end{document}
fontspec
needs to go first.
(Apparently it's not supposed to be necessary to load fontenc at all with lualatex: see here, but actually in this case, it seems to help because it looks for a TU encoded font first otherwise.)
EDIT 2: I came up with this answer by trial and error, not deep knowledge of best practices. For reasons Ulrike Fischer mentions in the comments to this answer, this may not be a great idea. You may encounter problems.
I haven't found any problems with hyphens, but you may.
For non-ascii characters, some of them work, some of them don't, but in my testing, the ascii LaTeX commands to produce non-ascii characters do generally work. For example, inserting ß
directly doesn't work, but \ss
does; using …
directly doesn't work, but \ldots
does and so on. How big a problem this is obviously depends on your use case. But I find that even with the non-ascii characters, it works to load the newunicodechar package and issue commands such as these at the end of the preamble:
\usepackage{newunicodechar}
\newunicodechar{ß}{\ss}
\newunicodechar{…}{\ldots}
\newunicodechar{—}{---}
% and so on
This allows me to use the non-ascii characters in my source. But my testing of this is not exhaustive, so use this answer with caution.
Best Answer
Using the
scrbook
-class of KOMA-Script:Serif-Font in all headings (chapter, section, etc.)
Or explicitly set the font with fontspec:
The result is identical if the standard serif font is Latin Modern Roman, you can set this with
\setromanfont{<fontname>}
:If you just want to change certain structure elements use e.g.
\addtokomafont{chapter}{}
or\addtokomafont{section}{}
etc:Using the standard
book
class and packagetitlesec
:You probably need to adjust the settings.