Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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} 

\begin{document}

\title{TEST 01} \maketitle

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


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

\end{document}

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

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

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

Code:

\documentclass{article}  
\usepackage{tikz} 
\usetikzlibrary{calc}

\begin{document}

\newcommand*{\Block}[3][]{%
    % #1 = tikz options
    % #2 = length of arrows
    % #3 = node text
    \begin{tikzpicture}[overlay]
    \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);
    \end{tikzpicture}
}%

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

\bigskip
Hello \Block[fill=green!20,draw=red,line width=1pt, anchor=west]{1.5cm}{test01 \\ test02}
\end{document}
share|improve this answer
add comment

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).

\documentclass[a4paper,10pt]{article} 
\newcommand*{\tto}{\!{\begin{array}{@{\hspace{1pt}}c}\rightarrow\\\rightarrow\end{array}}} 
\newcommand*{\block}[1]   {\fbox{\scriptsize ${\begin{array}{c}#1\end{array}}$}}
\begin{document}
Hello $\block{test01 \\ test02}\tto$.
\end{document}

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

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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