I have to write \Leftrightarrow quite often, and i am currently using a macro for it, but it isn't working too well. Is it possible to make it so that when i type LRA in a math field, that it then outputs it as a \Leftrightarrow?
Thanks a lot for any and all help!
Asked
Active
Viewed 367 times
3 Answers
1
\newcommand{\LRA}{\leftrightarrow} should do the trick. You can find more detailed information here, for example.
MaxD
- 1,137
-
1
-
1
-
Yes i am asking for LRA and not \LRA. By the way, how do you make that grey box around the important text, so to speak? – Chrisw85 Oct 29 '17 at 12:46
-
@MaxD
\iffis already defined. @Chrisw85 The grey boxes are created by ticks: ` – user2987828 Mar 12 '21 at 17:23
1
Following the suggestion in How could LaTeX replace the tokens <= by the command \leq?, you can use LuaLaTeX to replace all LRAs in your code with \Leftrightarrow:
\documentclass{article}
\usepackage{luacode}
\begin{luacode}
function do_LRA ( buff )
buff = string.gsub ( buff , "LRA", "\\Leftrightarrow ")
return buff
end
\end{luacode}
\AtBeginDocument{\directlua{luatexbase.add_to_callback (
"process_input_buffer" , do_LRA, "do_LRA" )}}
\begin{document}
$ <== LRA ==> L RA << >> LR A -+ +- L R A == LRA =[ =] $
The Literacy Research Association (LRA) \ldots
The Literacy Research Association (L{}RA) \ldots
\end{document}
Werner
- 603,163
1
Yes, it is possible. But it is questionable if it is usable.
The interesting point of your task is that you need not use \LRA but directly LRA. Then you can try the following code:
\mathchardef\mL=\mathcode`L
\mathcode`L="8000
{\catcode`L=13 \gdef L{\futurelet\next\lraA}}
\def\lraA{\ifx\next R\expandafter\lraB \else \mL\fi}
\def\lraB#1{\futurelet\next\lraC}
\def\lraC{\ifx\next A\expandafter\lraD \else \mL R\fi}
\def\lraD#1{\Leftrightarrow}
% test:
Aha LRA in text.
In math: $LR, L, LRA$
\bye
wipet
- 74,238

\LRAa shortcut for displaying\leftrightarrow. – Bernard Oct 28 '17 at 12:15SCHbecomes\chapter, while typingSSEbecomes\section). – Skillmon Oct 28 '17 at 12:24\leftrightarrow-- for example, this is easy with vim. – Oct 28 '17 at 13:08\leftrightarrow(or an error). – Peter Wilson Oct 29 '17 at 19:24