Is it possible a command like
\char{n}
where n is a number between 0 and 255? For example
\char{241}
returns ñ as output. I searched the web for something similar, even within this site, but I did not find anything
Is it possible a command like
\char{n}
where n is a number between 0 and 255? For example
\char{241}
returns ñ as output. I searched the web for something similar, even within this site, but I did not find anything
There is not anything called "the extended ascii" there are hundreds of ascii extensions "code pages" where the values between 128 and 256 might be accented latin letters as you have, or cyrillic, or Greek, or different accented letters depending on the encoding. So in latex you can use \symbol{241} (the latex syntax for \char241) but it depends on the encoding of the font you are using so normally you would never do that in a document.
If you use \symbol{241} in the body of the document but then change your font setup in the preamble you may get a different character with no warning or no character at all. The whole point about latex's encoding dependent commands like \~{n} is that the markup produces the correct character whatever numbers are used to access that character in the font being used.
\char at all and doesn't implement any of the lower level tex commands that you might find in definitions on this site.
– David Carlisle
Mar 01 '21 at 15:24
The \char macro is somewhat special in that it does not expect its argument to be enclosed in curly braces. If \char is followed by a number (say, 241), this number is taken to denote a base-10 number. If you write \char"F1, i.e., if you insert " after \char, the number (F1) will be interpreted to denote a hexadecimal number.
A full MWE:
\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
\char0241 \char"F1 % both will print out "ñ"
\end{document}
\char. – Mico Mar 19 '18 at 16:26fontencpackage with the optionT1, typing either\char0241or\char241prints out, you guessed it,ñ. A full MWE:\documentclass{article} \usepackage[T1]{fontenc} \begin{document} \char0241 \end{document}. Is that what you're trying to achieve? – Mico Mar 19 '18 at 16:35