2

I have an extra horizontal white space at the end of my pseudocode that I cannot get rid of with negative \hspace. Here is my minimal code:

\documentclass[journal,transmag]{IEEEtran}
\usepackage[ruled,linesnumbered]{algorithm2e}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}
something.
%
\SetKwInput{KwInputs}{Inputs}
\SetKwInput{KwOutput}{Output}
\SetKwInput{kwInit}{Init}
\SetAlCapSkip{1em}
\SetNlSty{textbf}{}{}
\SetNlSkip{0.8em}
\IncMargin{1em}
\begin{algorithm}[t]
\DontPrintSemicolon
\Indm
\KwInputs{inputs}
\KwOutput{outputs}
\Indp
$\theta_k=\tau_{k}$\;
\end{algorithm}
something else.

\end{document}

How can I get rid of the space before "something else"?

Thank you.

1

Every end of line after the % up to \begin{algorithm} contributes a space.

\documentclass[journal,transmag]{IEEEtran}
\usepackage[ruled,linesnumbered]{algorithm2e}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}
something.
%
\SetKwInput{KwInputs}{Inputs}%
\SetKwInput{KwOutput}{Output}%
\SetKwInput{kwInit}{Init}%
\SetAlCapSkip{1em}%
\SetNlSty{textbf}{}{}%
\SetNlSkip{0.8em}%
\IncMargin{1em}%
\begin{algorithm}[t]
\DontPrintSemicolon
\Indm
\KwInputs{inputs}
\KwOutput{outputs}
\Indp
$\theta_k=\tau_{k}$\;
\end{algorithm}
something else.

something. something else. % for checking
\end{document}

enter image description here

However, I usually advise of placing such floating objects between paragraphs, that is, with a blank line before and one below. So, in your case,

something. Something else.

\SetKwInput{KwInputs}{Inputs}
\SetKwInput{KwOutput}{Output}
\SetKwInput{kwInit}{Init}
\SetAlCapSkip{1em}
\SetNlSty{textbf}{}{}
\SetNlSkip{0.8em}
\IncMargin{1em}
\begin{algorithm}[t]
[...]
\end{algorithm}

Another paragraph starts here.

The spaces generated by the end-of-lines will do nothing in this case.

| improve this answer | |
  • another catch by the spurious-space catcher. you might want to mention that these spaces are not compressed into one by tex because they aren't contiguous. – barbara beeton May 3 '16 at 14:05
0

For IEEEtran class, USE "\par" to separate the content into two different paragraphs. The screenshot is attached for your reference. Hope this helps.

enter image description here

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