[Tex/LaTex] How to check if the selected letter is uppercase or lowercase in a macro

capitalizationmacrostexmaker

I'm using Texmaker and want to define some custom macros. The macros shall check if a selected letter is uppercase or lowercase and then replace that letter by a sequence defined in the macro. I need this macro to substitute turkish characters

  • \u{g} – ğ
  • \u{G} – Ğ
  • \c{c} – ç
  • \c{C} – Ç
  • \c{s} – ş
  • \c{S} – Ş
  • {\i} – ı
  • \.{I} – İ

but I don't want to manually select the uppercase or lowercase version of the character everytime. I did not find any reference to macros in the texmaker documentation and ixquicking latex uppercase macro turns up results with overly complicated scripts.

I want the macro to work like this: in the text 'Şimşek' I select the 'ş' and by pressing the hotkey assigned to my macro the letter turns into \c{s}. That same macro should turn
The 'Ş' into \c{S} when it is selected and the hotkey is pressed.

How what I define a macro to do just that?

Best Answer

I did not fully understand what you are trying to achieve, but you can check whether a string contains a letter, similar to this answer.

\documentclass{article}

\begin{document}

\makeatletter
\def\instring#1#2{TT\fi\begingroup
  \edef\x{\endgroup\noexpand\in@{#1}{#2}}\x\ifin@}
%
\def\isuppercase#1{%
  \instring{#1}{AÂBCÇDEFGĞHIİÎJKLMNOÖÔPRSŞTUÜÛVYZ}%
}%
\makeatother

\if\isuppercase{A}YES\else NO\fi

\if\isuppercase{a}YES\else NO\fi

\end{document}
Related Question