8

I would like to create a symbol for \implies and \impliedby where they are enclosed in a rotated lidless box as shown in the picture. Can anybody tell me how I could achieve this?

enter image description here

8

Welcome! You do not need any packages for that.

\documentclass{article}
\newcommand{\RightArrowInBox}{\begingroup
\renewcommand{\arraystretch}{0.6}\begin{array}{@{}c@{}|}\hline 
\raisebox{-0.2ex}{$\Rightarrow$}\\ \hline\end{array}\endgroup}
\newcommand{\LeftArrowInBox}{\begingroup
\renewcommand{\arraystretch}{0.6}\begin{array}{@{}c@{}|}\hline 
\raisebox{-0.2ex}{$\Leftarrow$}\\ \hline\end{array}\endgroup}
\begin{document}
$\RightArrowInBox~\LeftArrowInBox$
\end{document}

enter image description here

Of course you can modify the padding etc.

A version without cutting corners with major input by barbara beeton.

\documentclass{article}
\newcommand{\RightArrowInBox}{\begingroup
\renewcommand{\arraystretch}{0.6}\begin{array}{@{}c@{\rule[-3pt]{0.4pt}{0.85em}}}\hline 
\raisebox{-0.28ex}{$\Rightarrow$}\\ \hline\end{array}\endgroup}
\newcommand{\LeftArrowInBox}{\begingroup
\renewcommand{\arraystretch}{0.6}\begin{array}{@{}c@{\rule[-3pt]{0.4pt}{0.85em}}}\hline 
\raisebox{-0.28ex}{$\Leftarrow$}\\ \hline\end{array}\endgroup}
\begin{document}
$\RightArrowInBox~\LeftArrowInBox$
\end{document}

enter image description here

Or with trimclip.

\documentclass{article}
\usepackage{trimclip}
\newcommand{\RightArrowInBox}{\begingroup
\clipbox{0.5ex 0em 0em 0em}{\fbox{$\Rightarrow\!$}}\endgroup}
\newcommand{\LeftArrowInBox}{\begingroup
\clipbox{0.5ex 0em 0em 0em}{\fbox{$\Rightarrow\!$}}\endgroup}

\begin{document}
$\RightArrowInBox~\LeftArrowInBox$
\end{document}

enter image description here

| improve this answer | |
  • 2
    The corners aren't closed. Maybe add to the vertical two times the thickness of the rules. – barbara beeton Mar 30 at 1:13
  • 2
    @barbarabeeton Thanks! Yes, I know, we cats are famously good at cutting the corners. ;-) – Schrödinger's cat Mar 30 at 1:14
  • Hmm. Somehow, when adding corners, a little too much extra space got added below the arrows. (Nit picking.) The corners do look nice though. – barbara beeton Mar 30 at 2:47
  • @barbarabeeton This is entirely controlled by the height of the rule. If the requirement is to make it symmetric, then you can either make the rule higher, or raise the box a bit lower, or a combination of those. For instance, \raisebox{-0.275ex}{$\Rightarrow$} leads to a very symmetric positioning. I just am not sure if this is what the OP wants. – Schrödinger's cat Mar 30 at 2:51
5

Here's a solution which places \implies and \impliedby into a modified version of \fbox.

\documentclass{article}
\usepackage{amsmath}
\makeatletter
\def\@rframeb@x#1{%
  \@tempdima\fboxrule
  %\advance\@tempdima\fboxsep
  \advance\@tempdima\dp\@tempboxa
  \hbox{%
    \lower\@tempdima\hbox{%
      \vbox{%
        \hrule\@height\fboxrule
        \hbox{%
          %\vrule\@width\fboxrule
          #1%
          \vbox{%
            \vskip.7\fboxsep
            \box\@tempboxa
            \vskip.3\fboxsep}%
          #1%
          \vrule\@width\fboxrule}%
        \hrule\@height\fboxrule}%
                          }%
        }%
}
\DeclareRobustCommand\rfbox[1]{%
  \leavevmode
  \setbox\@tempboxa\hbox{%
    \color@begingroup
      \kern.2\fboxsep{#1}\kern.2\fboxsep
    \color@endgroup}%
  \@rframeb@x\relax}
\makeatother
\newcommand{\boximplies}{%
    \mathrel{\:\rfbox{$\Longrightarrow$}\:}%
}
\newcommand{\boximpliedby}{%
    \mathrel{\:\rfbox{$\Longleftarrow$}\:}%
}
\begin{document}
\( A \implies B \)

\( A \boximplies B \)

\( A \impliedby B \)

\( A \boximpliedby B \)
\end{document}
| improve this answer | |
5

Only array (that's a required package in every distribution):

\documentclass{article}
\usepackage{array}

\newcommand{\bimplies}{\mathrel{\bimpl{c|}{\Rightarrow}}}
\newcommand{\bimpliedby}{\mathrel{\bimpl{|c}{\Leftarrow}}}
\newcommand{\bimpl}[2]{%
  \begingroup
  \setlength{\arraycolsep}{0pt}%
  \renewcommand{\arraystretch}{0}%
  \begin{array}{#1}\hline{#2}\vphantom{+}\\\hline\end{array}%
  \endgroup
}

\begin{document}

$A\bimplies B\bimpliedby C$

\end{document}

enter image description here

| improve this answer | |
2

Try this overlay of two symbols. Too bad there is no big square left/right, so it requires rotation.

\usepackage{graphicx}
\usepackage{amssymb}

\newcommand\RightArrowInBox{%
 \rotatebox[origin=c]{90}{\ooalign{%
  \hfil$\Downarrow$\hfil\cr\noalign{\kern0.4pt}%
  \hfil$\bigsqcup$\hfil\cr}}}
\newcommand\LeftArrowInBox{%
 \rotatebox[origin=c]{-90}{\ooalign{%
  \hfil$\Downarrow$\hfil\cr\noalign{\kern0.4pt}%
  \hfil$\bigsqcup$\hfil\cr}}}

Other symbol collections like basic LaTeX or stmaryrd work better when inserting \displaystyle with the square or \scriptstyle with the arrow because the \bigsqcup is smaller than the version from amssymb.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.