[Tex/LaTex] Using inputenc package for cp1252 encoding

font-encodingsinput-encodings

I want to be able to use the ansinew characters in a latex document. According to the pdf file for the inputenc package, I can do that by putting \usepackage[cp1252]{inputenc} in my preamble. I do that, but when I put things like \guilsinglleft in my document, I get the error ! LaTeX Error: Command \guilsinglleft unavailable in encoding OT1. when compiling.

I'm not going into great detail here, because I assume I am making some very basic mistake, being new to latex.

Best Answer

The ... unavailable in encoding OT1 error means, as Herbert said, that your problem is related to your font encoding and can be solved by loading the appropriate font encoding.

As you said you are new to LaTeX, maybe you want to also read What packages do people load by default, where you can learn that if you load T1 font encoding, you should usually also load a vector font, for example lmodern, and probably the babel package (the order does not matter).

Also you could consider to use utf8 as input encoding instead of cp1252, because today most editors do support utf8 and maybe at some point your input will have characters that are not available in cp1252. But you can as well switch any time later.

Maybe some time later you want references, then you should take a look at biblatex and biber.

Putting all these hints together, you get a MWE that looks like this (as an answer to your question the 4 lines fontenc...lmodern are sufficient):

\documentclass[
    a4paper,
    final
]{scrartcl}

\usepackage[T1]{fontenc} % font encoding
\usepackage[utf8]{inputenc} % input encoding
\usepackage[french]{babel} % keyword translation and hyphenation
\usepackage{lmodern} % lmodern looks better than cm-super

\usepackage[
    babel=true,
    verbose=true
]{microtype}

\usepackage[]{graphicx} % if you want figures
\usepackage[autostyle]{csquotes} % quotes

\usepackage[
    backend=biber,
    style=authoryear-icomp,
    sortlocale=fr_FR,
    natbib=true,
    url=false, 
    doi=true,
    eprint=false
]{biblatex}
\addbibresource{biblatex-examples.bib} % just an example
%\addbibresource{\jobname.bib} % include your own bib file

\usepackage[]{hyperref}
\hypersetup{
    colorlinks=true,
}


%% ===========================
\begin{document}

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, 
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, 
sed diam voluptua. 
At vero eos et accusam et justo \citet{kastenholz} et ea rebum. 
Stet clita kasd gubergren, 
no sea takimata sanctus est Lorem ipsum dolor sit amet. 

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, 
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, 
sed diam voluptua. 
At vero eos et accusam et justo duo dolores et ea rebum. 
Stet clita kasd gubergren, 
no sea takimata sanctus est Lorem ipsum dolor sit amet~\citep{sigfridsson}.

\printbibliography 

\end{document}