2

I have following code:

\documentclass[10pt,journal,compsoc]{IEEEtran}
\hyphenation{op-tical net-works semi-conduc-tor}
\usepackage{graphics}
\usepackage{mdframed}
\usepackage{tikz}
\usepackage{subfigure}
\usepackage{float}
\restylefloat{table}
\usepackage{enumitem,kantlipsum}
\usepackage{framed}
\usepackage{wrapfig}

\begin{document}
\title{hi}
\maketitle
\IEEEdisplaynontitleabstractindextext
\IEEEpeerreviewmaketitle
\IEEEraisesectionheading{\section{Introduction}\label{sec:introduction}}

Blockchain
% Here first framed box fills complete first column.
\begin{framed}
 \scriptsize 
 Hello World. \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\  \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\
 \end{framed} 

% On the second framed box on top right column there is additional space shows up.
\begin{figure}[htbp]
\begin{framed}
 \scriptsize 
 Hello World.
 \end{framed} 
 \vspace*{-5.0mm}
 \caption{Caption.} 
\end{figure}

Some text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text.
\end{document}

The output I get is:

enter image description here

You can see additional newline after the caption. I want to decrease the space right after the framed figure's caption, is it possible? Please note that I want to see my framed-box as a figure. The output I would like to have as follows:

enter image description here

[Q] How could I remove space after framed figure's caption and text follows it?

  • 2
    Welcome to TeX.SX! Please help us help you by adding a minimal compilable document (MWE) illustrating the issue. – TeXnician Aug 12 '18 at 17:22
  • Where does \begin{verbatim} end? What's your document class? "Compilable" means that it can he compiled... – marmot Aug 12 '18 at 17:27
  • See if replacing the center environment with the \centering directive is enough. figure adds vertical spacing, and center adds another – this is too much. – Bernard Aug 12 '18 at 17:29
  • I am sorry, I forget to add, right after % Hello World. but for experiment you can leave it as empty. Document class is: \documentclass[10pt,journal,compsoc]{IEEEtran} @marmot – alper Aug 12 '18 at 17:29
  • Please add all that to the code of your question. – marmot Aug 12 '18 at 17:31
2

Like this?

\documentclass[10pt,journal,compsoc]{IEEEtran}

\usepackage{framed}

\begin{document}
\setlength{\abovecaptionskip}{0ex}
\begin{figure}[htbp]
\centering
\setlength{\OuterFrameSep}{0pt}
 \begin{framed}
 \scriptsize \bfseries
   \begin{verbatim}
    % Hello World.
   \end{verbatim}
 \end{framed}
  \caption{Caption.} \label{fig:sig}
\end{figure}
\vspace{-1ex}

Some text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text.

\end{document} 

enter image description here

For the second code, same method: set \OuterFrameSep to 0, \abovecaptionskip to a smaller value than the default, and insert a negative vertical space after the caption:

\documentclass[10pt, journal, compsoc]{IEEEtran}
\hyphenation{op-tical net-works semi-conduc-tor}
\usepackage{graphics}
\usepackage{mdframed}
\usepackage{tikz}
\usepackage{subfigure}
\usepackage{float}
\restylefloat{table}
\usepackage{enumitem,kantlipsum}
\usepackage{framed}
\usepackage{wrapfig}

\begin{document}
\title{hi}
\maketitle
\IEEEdisplaynontitleabstractindextext
\IEEEpeerreviewmaketitle
\IEEEraisesectionheading{\section{Introduction}\label{sec:introduction}}

Blockchain
% Here first framed box fills complete first column.
\begin{framed}
 \scriptsize
 Hello World. \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\
 \end{framed}

% On the second framed box on top right column there is additional space shows up.
\begin{figure}[htbp]
    \setlength{\OuterFrameSep}{0pt}
    \setlength{\abovecaptionskip}{0pt}
\begin{framed}
 \scriptsize
 Hello World.
 \end{framed}
 \caption{Caption.}
\vspace*{-3ex}
\end{figure}
Some text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text.

\end{document} 

enter image description here

  • This works! But when I am use two framed box right after, (1st one in on the complete first column and second one is on the top of the second column), which still causes the problem I do not know why. – alper Aug 12 '18 at 18:12
  • Could you please have a look on my updated answer where I give the example with double columns. @Bernard – alper Aug 12 '18 at 18:23
  • 1
    @alper: I've added a solution for the new case, with some explanations. Is it like you want? – Bernard Aug 12 '18 at 19:54
  • 1
    You can add \vspace*{-\FrameSep} after \end{verbatim}. I don't know the reason for this extra spacing. Maybe this is linked to the verbatim environment. – Bernard Aug 12 '18 at 21:58
  • 1
    Maybe. I've checked it's probably linked to verbatim. In the meanwhile, here is a work-around: \begin{figure}[htbp] \setlength{\OuterFrameSep}{0pt} \setlength{\abovecaptionskip}{0pt} \setlength{\FrameSep}{0.6ex} \begin{framed} {\scriptsize \begin{verbatim} event LogSetJob(address clusterAddress, string jobKey, uint32 index, uint startTime) } \end{verbatim} } \vspace*{-\baselineskip} \end{framed} \caption{Caption.} \label{fig:sig} \vspace*{-2ex} \end{figure}. – Bernard Aug 12 '18 at 22:24

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.