2

The code:

 \begin{figure}
 \begin{Verbatim}[frame=single,
framesep=5mm]
<pick ...>
  <onMessage resolveByBPELEngine="true">
    ...
  </onMessage>
  ...
</pick>
\end{Verbatim}
\caption{Pick Activity}~\label{fig:ResolvingPickActivity}
\end{figure}

enter image description here

How could I resize the width to make it fit to the code inside? It is ok for setting a value for let say a width attribute statically.

4

One way to do this is to use fancyvrb's saving mechanism and then place the material in an `\fbox' appropriately defining the separation at that stage:

Sample output

\documentclass{article}

\usepackage{fancyvrb}

\begin{document}

\begin{figure}
  \centering
  \begin{SaveVerbatim}{VerbCode}
<pick ...>
  <onMessage resolveByBPELEngine="true">
    ...
  </onMessage>
    ...
</pick>
\end{SaveVerbatim}
  \setlength{\fboxsep}{5mm}
  \fbox{\BUseVerbatim{VerbCode}}
  \caption{Pick Activity}~\label{fig:ResolvingPickActivity}
\end{figure}

\end{document}

The SaveVerbatim environment saves the contents in the given name, here VerbCode. This is then reused with \BUseVerbatim.

2

The boxedverbatim-environment of the moreverb-package does exactly this. Here is an example:

\documentclass{article}
\usepackage{moreverb}

\begin{document}

\begin{figure}
\centering
\begin{boxedverbatim}
<pick ...>
  <onMessage resolveByBPELEngine="true">
    ...
  </onMessage>
  ...
</pick>
\end{boxedverbatim}
\caption{Pick Activity}~\label{fig:ResolvingPickActivity}
\end{figure}

\end{document}

Note: If you want more sophisticated formatting (with syntax coloring etc), take a look at the listings-package (but no fitting of the box around the code, unfortunately)

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.