2

Suppose I have this textual code:

foo(a, b, c)

I want to typeset it such that in the result .pdf file it appears this way:

foo(a,
    b,
    c)

In addition, ChatGPT provides a "solution" that looks like

    a,
foo(b,)
    c

which is unacceptable.

My actual result is: enter image description here

... and the culprit code is:

$\textsc{Enlarge-Finger-Array-With-Empty-Range}(
  \begin{array}{@{}l@{}}
    L, \\
    L.F.size + 2, \\
    \texttt{beforeFingerIndex}, \\
    1, \\
    1
  \end{array}
)$ \\

How can I achieve this?

2
  • 1
    Could u provide two versions of complete code instead of just show the result? Thanks! Commented Jul 6 at 7:09
  • @Explorer I added the image of my result and the LaTeX snippet used for typesetting it. Commented Jul 6 at 7:27

1 Answer 1

4

Use \begin{array}[t].

Here I provide a version that lets you choose whether stacking or not.

\documentclass{article}
\usepackage{algorithm2e}

\ExplSyntaxOn
\NewDocumentCommand{\FUNC}{smm}
 {
  \textsc{#2}(
  \IfBooleanTF{#1}
   {% inline
    #3)
   }
   {
    \begin{array}[t]{@{}l@{}}\clist_use:nn {#3}{, \\} ) \end{array}
   }
 }
\ExplSyntaxOff

\begin{document}

\begin{algorithm}
\SetKwInOut{Input}{input}\SetKwInOut{Output}{output}
\Input{Your input}
\Output{Your output}
\BlankLine
$\FUNC{Enlarge-Finger-Array-With-Empty-Range}{
  L, L.F.\mathit{size} + 2, \texttt{beforeFingerIndex}, 1, 1
}$ \\
Whatever you need \\
Inline function $\FUNC*{Foo}{a,b,c}$
\end{algorithm}

\end{document}

output

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.