# Do I need to use \usepackage[T1]{fontenc} if I use lualatex?

When producing documents with pdflatex that may contain special utf-8 characters, it is recommended to add the following to the preamble

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}


I know that with lualatex the inputenc line is not necessary, since everything is set up to use utf-8 encoding by default. But I don't know what to do about that fontenc line. Do I need to include it or not if I am using lualatex?

• See @egreg's answer here. Spoiler alert, the answer is no. But I don't know exactly why, so I'll not answer the question. – Phelype Oleinik Jan 29 '18 at 21:18
• no you should not have either of those lines for luatex – David Carlisle Jan 29 '18 at 21:19
• Short answer: no. Long answer: NO. – user139954 Jan 29 '18 at 22:47
• You can if you use the luainputenc package instead of inputenc. But it is mainly for backward compatibility with old (PDF)LaTeX documents. If you really want to stick to the old input and font encodings, better use (PDF)LaTeX instead of LuaLaTeX. – Franck Pastor Jan 29 '18 at 23:09
• As I understand it, somebody might want that line. However, that's only true if you know precisely why you want it and what the consequences are. If you aren't sure whether you need it, not only don't you need it, you shouldn't have it. Consider \usepackage{fontspec} instead. – cfr Jan 30 '18 at 0:17

If you want to use pdflatex, you should use in your preamble:

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}


If you want to use lualatex or xelatex, you should use in your preamble:

\usepackage{fontspec}
\setsansfont{CMU Sans Serif}%{Arial}
\setmainfont{CMU Serif}%{Times New Roman}
\setmonofont{CMU Typewriter Text}%{Consolas}


If you want to compile your document time to time with lualatex or with pdflatex without changing preamble, you can use ifluatex package. Typical preamble for this purpose can looks like:

%%============================ Compiler Directives =======================%%
%%                                                                        %%
% !TeX program = lualatex
% !TeX encoding = utf8
% !TeX spellcheck = english
%%                                                                        %%
%%============================== Document Class ==========================%%
%%                                                                        %%
\documentclass[14pt]{article}
\usepackage{ifluatex}
%%                                                                        %%
%%========================================================================%%

\ifluatex
\usepackage{fontspec}
\setsansfont{CMU Sans Serif}%{Arial}
\setmainfont{CMU Serif}%{Times New Roman}
\setmonofont{CMU Typewriter Text}%{Consolas}
\defaultfontfeatures{Ligatures={TeX}}
\else
\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
\fi

\usepackage[english]{babel}

\begin{document}

\end{document}


No, Luatex does not require using the fontenc package.