I have a problem with a \fbox command: I want to put two right-arrow side to the box so that these two arrows start on the border of the box. I've created the box and the two arrows but if I merge it together there is an annoying space between the end of the border of the box and the starting of the two arrows, as you can see if you compile this MWE:

\documentclass[a4paper,10pt]{article}  \usepackage[english]{babel} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{amsmath}  \usepackage{amssymb} 


\title{TEST 01} \maketitle

\newcommand*{\block}[1]   {\fbox{\scriptsize ${\begin{array}{c}#1\end{array}}$}}

Hello $\block{test01 \\ test02}\tto$.


How can I stick the two arrows to the right border of the fbox?


Here is a tikz version. The \Block macro accepts three options which allows you to customize the drawing/filling/location of the box, the length of the arrows, and the text to be displayed in the box.

enter image description here




    % #1 = tikz options
    % #2 = length of arrows
    % #3 = node text
    \node [align=left, draw=black, right, anchor=south west, font=\scriptsize, #1] (B) {#3};
    \draw [-latex, thick] ($(B.south east)!0.25!(B.north east)$)-- ++(#2,0);
    \draw [-latex, thick] ($(B.south east)!0.75!(B.north east)$)-- ++(#2,0);

Hello \Block[fill=cyan!20]{1.0cm}{test01 \\ test02}

Hello \Block[fill=green!20,draw=red,line width=1pt, anchor=west]{1.5cm}{test01 \\ test02}

This is caused by the space that is automatically inserted at the left of an array. You can set your own space using @ (see page 48 of the not so short guide for details).

\newcommand*{\block}[1]   {\fbox{\scriptsize ${\begin{array}{c}#1\end{array}}$}}
Hello $\block{test01 \\ test02}\tto$.

Having said that, you might get better results using tikz.

  • I've used this solution because I also have to overbrace the fbox in some cases. Thanks a lot. – escap Jul 18 '12 at 9:55

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.