I am trying to typeset a book that uses the diacritics used in Romanian language. As I have to use a specific font, I had to "construct" the characters using something like that:
\newcommand\chara {a}
\newcommand\charA {A}
\makeatletter
\def\kernbrevea#1{\kern#1\dimexpr0.47em-\strip@pt\fontdimen1\font\dimexpr-0.2em\relax\relax}
\def\kernbreveA#1{\kern#1\dimexpr0.56em-\strip@pt\fontdimen1\font\dimexpr-0.34em\relax\relax}
\makeatother
\catcode`\ă=\active
\def ă{\raisebox{.0em}\u\kernbrevea{-}{\chara}\kernbrevea{+}\kernbrevea{-}}
\catcode`\Ă=\active
\def Ă{\raisebox{.24em}\u\kernbreveA{-}{\charA}\kernbreveA{+}\kernbreveA{-}}
The result is satisfactory. I managed to build support for using the truetype files I need (following various tutorials I had found floating around the net) and it seems to work ok, except for the situation when this letter ends up at the end of a line in an paragraph. Something like this:
I suspect that there is something about the code after the \def commands above but I have to admit I am a complete novice to LaTeX and I gave up trying to understand the syntax for the commands listed... I have taken them nearly unchanged from another examples and might very well be quite stupid, I have no idea. Can anyone help me with a solution to this problem?
I know I should be switching to another font that has no problems but unfortunately I have to use this specific variant of ElegantGaramond.
Thank you!
Later edit
Ok, so the two main problems were solved: using romanian diacritics with a broken (probably) font. LaTeX did its best and allowed me to show those.
But now I have an annoying problem. This is the code that I have isolated that has everything I am interested included:
\documentclass[10pt,a4paper,openany]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[romanian]{babel}
\usepackage{pxfonts}
\usepackage{eg}
\pdfmapfile{+eg.map}
\begin{document}
\newcommand\chara{a}
\newcommand\charA{A}
\newcommand\chars{s}
\newcommand\charS{S}
\newcommand\chart{t}
\newcommand\charT{T}
\makeatletter
\def\kernbrevea#1{\kern#1\dimexpr0.47em-\strip@pt\fontdimen1\font\dimexpr-0.2em\relax\relax}
\def\kernbreveA#1{\kern#1\dimexpr0.56em-\strip@pt\fontdimen1\font\dimexpr-0.34em\relax\relax}
\makeatother
\catcode`ă =\active
\def ă{\raisebox{.0em}\u\kernbrevea{-}{\chara}}
\catcode`Ă=\active
\def Ă{\raisebox{.24em}\u\kernbreveA{-}{\charA}\kernbreveA{+}\kernbreveA{-}}
\catcode`ş=\active
\def ş{\c{\chars}}
\catcode`Ş=\active
\def Ş{\c{\charS}}
\catcode`ţ=\active
\def ţ{\c{\chart}}
\catcode`Ţ=\active
\def Ţ{\c{\charT}}
Some test text using romanian diacritics:
şŞţŢăĂîÎâÂ
Kerning: hăh măh xăx VĂV WĂW
\end{document}
This renders as in the image:
So the text looks good, BUT some unwanted stuff appears. Obviously, the twice appearing "=," is not intended... And ok, I can understand that something from the line "\catcode`\ă=\active" is generating this, since in the logs I have this:
! Missing number, treated as zero.
<to be read again>
\protect
l.26 \catcode`ă
=\active
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Package inputenc Error: Keyboard character used is undefined
(inputenc) in inputencoding `utf8'.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
...
l.26 \catcode`ă
=\active
You need to provide a definition with \DeclareInputText
or \DeclareInputMath before using this key.
! Missing number, treated as zero.
<to be read again>
\protect
and two similar errors are generated from the ș definition. What I don't understand is why the other definitions (apparently identical in form or syntax) aren't generating errors?
I've made a zip file all.zip available for 10 days from wetransfer that probably has all the files to reproduce the document, in case someone wants to replicate the problem. Most probably I am quite illiterate in LaTeX to understand where is the problem. All I can do is look perplexed in the code...
Thank you for your help.



\u{a}and\u{A}not working for you -- or not appropriate for some reason? (I will admit to not being familiar with the particulars of the font called "Elegant Garamond".) – Mico Feb 28 '17 at 14:36\u{a}? – egreg Feb 28 '17 at 15:00\Ăin pdflatex if you are using ITF-8 encoding. but it is not clear why the standard inputenc commands are not sufficient – David Carlisle Feb 28 '17 at 15:01utf8was indeed a *big* problem. Doing\catcode`ă=\activeproduces an error in that case, so I assumed a different setup with an 8-bit encoding. – egreg Mar 03 '17 at 15:24