# Redefine encoding to input custom characters using inputenc

I want to reassign different values to characters so that, e.g., when I type a '¤', an 'l' gets output into the pdf file.

To achieve this, I use the inputenc package and modify one of its *.def files where characters that the user inputs from the keyboard are mapped to characters that will be printed in the output.

Here is the MWE which I compile with pdfLaTeX:

\documentclass{article}
\usepackage[latin1]{inputenc}
\begin{document}
¤¦
\end{document}


As you can see, I use the latin1 encoding. I modified the corresponding latin1.def file as follows:

...
...
\DeclareInputText{164}{l}
\DeclareInputText{166}{i}
...
...


This means that slots 164 and 166, which correspond to the characters "¤" and "¦" in the Latin-1 table (see the ASCII / ISO 8859-1 table spec), respectively, are to be replaced with plain "l" and "i".

The result, however, is this:

Why do the offending "Â"s get into my document and how to get rid of them?

• Your file is utf8 encoded, not latin1. And don't modify the original def-files. – Ulrike Fischer Oct 5 '18 at 8:30
• Changing input file's encoding to latin1 helps. I actually copied the original file from inputencs folder structure and modified a copy locally. – Rokas Oct 5 '18 at 8:42
• There is no reason to call your modified file latin1.def and 1001 reasons not to call it that. Call it foobar.def then use \usepackage[foobar]{inputenc} – David Carlisle Oct 5 '18 at 8:50
• your example was remapping some little used characters but in the text of your question you said you wanted to map "0, an a" If you redefine digits like 0 essentially everything will break, you will not to be able to set any lengths or counters. – David Carlisle Oct 5 '18 at 8:53
• The "0 to a" was just an example, though I agree, maybe not the best one. I understand that digits are best left as is, so I chose some more rarely-used characters. – Rokas Oct 5 '18 at 8:59

The presence of Â in the printout is a clue that your file is actually UTF-8 encoded.

If I save this example file

% -*- coding: latin-1 -*-
\documentclass{article}
\usepackage[latin1]{inputenc}
\DeclareInputText{164}{l}
\DeclareInputText{166}{i}

\begin{document}
¤¦
\end{document}


(the top line is for telling Emacs I really want the file to be Latin-1/ISO8859-1 encoded, your editor may have a similar trick) and compile it, I get