Skip to main content

Questions tagged [pseudocode]

{pseudocode} is a compact and informal description of a computer programming algorithm.

Filter by
Sorted by
Tagged with
2 votes
1 answer
63 views

In pseudo-codes, how to get newline in the same state?

I want to generate a pseudo-code similar to the image: Here's what I tried (I modified a bit the content of the code, but the idea is clear). In Inputs, splitting components in different lines with ...
Guesttilunderstandingnature's user avatar
1 vote
1 answer
25 views

algorithm2e does not set \texttt

I have algorithms that I wrote in algorithm2e. But I want the name of the function written in typewriter. As you see in the picture, this does not work, I get this strange font: Here is my MWE: \...
Lereu's user avatar
  • 471
2 votes
0 answers
23 views

pseudocode, clever-ref. display (algorithm number, line of code)

I have several algorithms and want to be able to have clever-ref automatically generate citations like \cref{alg1-line1}: Algorithm 1, Line 1 \cref{alg2-line44}: Algorithm 2, Line 44 preferably with ...
Alek Westover's user avatar
0 votes
0 answers
40 views

Latex Pseudocode missing number cannot resolve

\begin{algorithm} \caption{LexBFS Algorithm} \begin{algorithmic}[1] \Function{LexBFS}{$G=(V, E)$} \State Let $P$ be an empty list \Comment{Initialize the permutation} \State Let $Q$ be an empty queue \...
n.y's user avatar
  • 1
0 votes
2 answers
55 views

Algpseudocode, for-next loop: control variable in next line

In this pseudo-code excerpt, is it feasible to add a new argument for the variable v with a syntax like \ForAll {$v$}{$v \in V(G)$} to get the output next v? \documentclass{article} \usepackage{...
Jh0an1 Uzca73gu1's user avatar
0 votes
1 answer
68 views

How can I achieve this non-restrictive pseudocode style?

What is the best way (as in most efficient) way of writing pseudocode like below? In particular I like that it is well-structured but gives enough freedom in writing (in reality it it is just ...
Yuumita's user avatar
  • 131
1 vote
1 answer
15 views

How do I create an aligned column of text before the numbers in a "pseudo" environment?

I want to create a "diff" effect using the pseudo package, inspired by GitHub/Gerrit diffs. However, the symbols at the start of the line aren't lined up - they move when the digits go from ...
Paul Crowley's user avatar
0 votes
0 answers
39 views

I am facing problem in Pseudocode overleaf error Underfull \hbox (badness 10000) in paragraph at lines 615--615 ,Extra }, or forgotten \endgroup

this error I am getting Extra }, or forgotten \endgroup. Extra }, or forgotten \endgroup. Argument of \Return has an extra }. Underfull \hbox (badness 10000) in paragraph at lines 615--615 Runaway ...
Noora noona's user avatar
0 votes
1 answer
30 views

if else loops and repeat until loops doesn't work with algorithm package

code: \begin{algorithm}[!t] \begin{algorithmic}[1] \caption{Adaptive Random Search}\label{algo_ARS} \State define the probability of local search as $P_s$ and global search as 1 - $P_s$ \Repeat ...
Rolphnol's user avatar
0 votes
1 answer
42 views

how to fix the issue in pseudo code algorithms with multiple precedures in latex?

I am formetting pseudo code algorithms with multiple procedures in it, but formatting has somes issues such as endProcedure=0in latex output though. How can I fix this? thanks my current script \...
kim's user avatar
  • 103
2 votes
2 answers
959 views

How to write a "repeat n times" loop in algorithmic?

In algorithmic, I would like to write a loop that will look like the following: repeat $n$ times: [command] end I found this question, explaining how to do this in algorithms2e, but it ...
Erel Segal-Halevi's user avatar
1 vote
2 answers
54 views

Why is my symbol look so sparse in the pseudo code?

\documentclass[twocolumn]{ltxdoc} \usepackage{amsmath} \usepackage{newtxtext,newtxmath} % \usepackage{lineno} \usepackage{algorithm} \usepackage{algpseudocode} \usepackage{amsmath} \usepackage{...
James's user avatar
  • 415
0 votes
0 answers
60 views

How to write table in overleaf?

I hope you are doing very well. I am writing a report for my class. I need to add code like this in my latex report. But I haven't found any similar example from google. I just recently started using ...
ya xi er's user avatar
1 vote
2 answers
191 views

Reduce font size of particular line in algorithm and algorithmic pseudocode

I want to reduce the font size of a particular line in an algorithm pseudocode where I use algorithm and algorithmic package. How can I do it? For example in the following I want to fit line 9 in one ...
melatonin15's user avatar
0 votes
1 answer
156 views

Background coloring in algorithm2e pseudocode in beamer

I tried to highlight parts of my pseudocode in algorithm2e with the following answer to a similar question: https://tex.stackexchange.com/a/51590/287916. I copied the code exactly the same and run it, ...
Michelle's user avatar
1 vote
1 answer
180 views

Cryptocode pseudocode: ignore a single line's column sizes

I'm writing a 2-player protocol with cryptocode's pseudocode, and have a while condition which applies to both players. Since the while condition is long it shifts the other columns far to the right, ...
Benjamin Lieber's user avatar
0 votes
1 answer
34 views

How to get the correct number corresponding to the line in pseudocode? [closed]

\begin{algorithm} \caption{Random Vector Generation} \begin{algorithmic} \State Generate $\mathit{n}$ random variables $\mathit{U_{1},...,U_{n}}$ as iid variables from $\mathit{U(0,1)}$ \newline \...
VRN NRV's user avatar
0 votes
0 answers
384 views

Does anybody know how to draw this pseudo code diagram?

I want to draw this pseudo code in latex, can anybody help me? This is the code I created, however, it somehow doesn't match the requirement, can anybody help me to modify the code? \documentclass[...
James's user avatar
  • 415
0 votes
1 answer
329 views

The LaTex template offered by AIP cannot be inserted pseudocodes [duplicate]

In order to submit to Chaos, I downloaded the Latex Template AIP requests. But when I was going to insert the pseudo code like \begin{algorithm} %\textsl{}\setstretch{1.8} \renewcommand{\...
user277103's user avatar
0 votes
0 answers
54 views

Why pseudo code and tables don't show in pdf version?

I am writing a research paper using an official template. When I run .tex file, it shows all the text and images, but it does not show tables and pseudo code (Even packages are included). Please have ...
Yasir Glani's user avatar
0 votes
1 answer
52 views

How can I have two spaces before the broken lines in inputlisting?

I am using the solution from How can I write line numbers inside boxed code. Its code with slightly changes: \begin{filecontents*}{\jobname.sol} function hello_world(uint a, uint b, uint c, uint d,...
alper's user avatar
  • 1,515
0 votes
0 answers
308 views

Goto command in algorithm2e package

I use the following code N(a,n,i,j,y){ $p \gets 1$\; $z \gets 1$\; \While {$z \leq n$}{ \eIf{$a[y][z] = 0$} { $z \gets z+1$\; }{ ...
Vikram Srinivasan's user avatar
2 votes
2 answers
438 views

How can I write line numbers inside boxed code

I am trying to show a code-piece inside a box. I was wondering is it possible to has its line numbers inside the box as well, shifting code little to the right? I have following code: \expandafter\def\...
alper's user avatar
  • 1,515
1 vote
1 answer
464 views

How to remove Algorithm 1 from header and how to declare a variable with its type

I'm trying to write my first pseudocode algorithm with MikTEX and algorithm2e package but there are at least two things that I cannot understand. The image below shows what I want to achieve in term ...
Bender's user avatar
  • 111
0 votes
0 answers
60 views

Conventions for Distinguishing a Property when Describing Different Objects

I have several objects, in this case they are indexed sequences which are used in an algorithm written in pseudo-code and in mathematical expressions. For example, there is $V$ and $S$, and there is a ...
MVTC's user avatar
  • 101
0 votes
1 answer
93 views

How to add vertical line next to code numbers and change background colors

I am using the listings package. With the code below I get a result like this I want to draw a line next to the line numbers like below. Also if possible I would like to change the background color ...
Moses Kim's user avatar
  • 183
1 vote
1 answer
185 views

Loop statement without ending

I'm using usepackage{algpseudocode} for my pseudocode in latex, but I found after the loop statement there's only an end statement rather than end for. What went wrong with my algorithm. The rest of ...
Reyha's user avatar
  • 75
1 vote
1 answer
343 views

Disable algorithmic line numbers with IEEE template

I want to disable line number in pseudo-code blocks, even though there isn't 1 in the \begin block. I am using the IEEE template This is the code \begin{algorithm} \caption{Test} \begin{algorithmic} ...
Aleksandar Ivanovski's user avatar
6 votes
1 answer
2k views

Best practices for typesetting pseudocode

I need to typeset the pseudocode of several pieces of code in latex. I found in this answer a good overview of the three main packages available to render pseudocode. In the following I will adopt the ...
Sirion's user avatar
  • 245
1 vote
1 answer
980 views

Placing pseudocode between paragraphs

I am trying to re-write a line of an algorithm's pseudocode, and I would like to be able to present it in-text rather than introducing another floating algorithm environment. How can I do this? Here ...
Dallan's user avatar
  • 113
2 votes
1 answer
857 views

How can I adjust nested if statements in the algpseudocode package

I have the following code: \documentclass{article} \usepackage{algorithm} \usepackage[noend]{algpseudocode} \begin{document} \begin{algorithm} \caption{Main D Algorithm}\label{alg:cap} \begin{...
Sergio's user avatar
  • 169
9 votes
0 answers
1k views

Highlighting pseudocode in algorithm

Edit: I "solved" my main issues now. It's a bit ugly/hacky, but at least the result looks ok. With this edit I'm replacing the now obsolete old code with what I have now. But suggestions for ...
Hansli's user avatar
  • 91
1 vote
0 answers
25 views

How to eliminate indentation when using command "\For{}" in the "algorithm environment"

I do not want an indentation for the "For loop." How can I make it aligned with the "Require" text? \documentclass{article} \usepackage{amsmath,amssymb} \usepackage[utf8]{inputenc} ...
JuanMuñoz's user avatar
  • 1,474
1 vote
1 answer
55 views

how to eliminate automatic indentation in pseudo code

In the code, one of the lines has an automatic indentation. How can I eliminate the indentation(it is the line after the command "\Endwhile")? \documentclass{article} \usepackage{amsmath,...
JuanMuñoz's user avatar
  • 1,474
0 votes
0 answers
298 views

How to format really long sentence in for loop pseudocode?

I have the following code for an algorithm. \begin{algorithm} \label{alg:script} \caption{Algorithm to calculate something} \begin{algorithmic}[1] \State One line sentence \...
user42's user avatar
  • 125
1 vote
0 answers
79 views

How to Display Pseudocode with New Commands [duplicate]

I want to write pseudocode in TeXShop, with my own commands. The only commands I need to have are save, repeat, return, and if/elif/else. Can someone please help me with that? I was trying to figure ...
alleycat's user avatar
0 votes
0 answers
475 views

Writing multiline equation inside algorithmic pseudocode environment

I have the following code which produces the algorithm in the image. \documentclass{article} \usepackage{algorithm} \usepackage{algorithmicx} \usepackage{algpseudocode} \begin{document} \begin{...
David's user avatar
  • 101
0 votes
1 answer
515 views

Not able to get proper for loop and if

\usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm} \caption{Brute-Force algorithm} \begin{algorithmic}[1] \For {$s'$ \in ${\mathbb{F}^n_2}$}{ \If {$wt(As'+b)$ \...
Atul Sharma's user avatar
2 votes
1 answer
244 views

Formatting a Pseudocode using Algorithm2e

I'm trying to format a pseudocode using the Algorithm2e package. The desired output has the following format: Here's the code I've tried to format this pseudocode: \usepackage[ruled,vlined]{...
IGY's user avatar
  • 121
2 votes
2 answers
827 views

How to make the pseudo code more compact?

I wrote the following piece of pseudo code. It shows the result as shown in the figure below. I think there is too much white space above the horizontal line in the picture. I want to make them more ...
Yujie's user avatar
  • 175
-1 votes
1 answer
78 views

how can i correct this mistakes, i tried a lot

\documentclass[a4paper,11pt]{article} \usepackage{algorithm} \usepackage{commath} \usepackage{algpseudocode} \begin{document} \begin{algorithm} \caption{Game Theory Controller} {\textbf{...
Qussay A. Ameer's user avatar
-1 votes
1 answer
117 views

! LaTeX Error: \caption outside float. when creating pseudocode algorithm in Latex

Here's my code : \usepackage{algorithmic} \begin{algorithm} \caption{Calculate $A_{nxn}$} \label{Algorithm 1} \begin{algorithmic} \begin{enumerate} \item ... \end{enumerate} \end{algorithmic} \...
Sam's user avatar
  • 101
1 vote
1 answer
2k views

Pseudocode: "If not" control structure

I use the following packages: \usepackage{algorithm} \usepackage{algpseudocode} to display pseudocode of some algorithms in my latex document. For conditionals I use the follow \If{success = 0} \...
gen's user avatar
  • 113
-1 votes
1 answer
300 views

Can you show me how to make this pseudocode using `LaTeX`?

Can you show me how to make this pseudocode using LaTeX?
Hyungjin Park's user avatar
2 votes
1 answer
197 views

Pseudocode in the style of Algorithm Design (Kleinberg & Tardos)

How do you write pseudocode in the style below? I tried using the verbatim environment but I can't seem to get the variables italicized and symbols like \in to work. I also tried using the algorithmic ...
nvi's user avatar
  • 23
2 votes
2 answers
13k views

Why do I get "Require" and "Ensure" instead of "input" and "output" phrases in my pseudocode in IEEE Access format?

When I wrote the following pseudocode in \documentclass{article} format, I get "Input" and "Output" phrases after the compilation but when I write the same latex code in the IEEE ...
esra's user avatar
  • 173
0 votes
1 answer
2k views

Cannot write my pseudocodes in IEEE Access format?

I am trying to write an IEEE Access paper by using the template on their website. But I am having trouble writing my pseudocodes since there is no pseudocode example in their template. When I use ...
esra's user avatar
  • 173
2 votes
2 answers
1k views

Using a matrix as a parameter in an algorithm

I'm trying to write a pseudocode algorithm in LaTeX, where one of the functions needs to have matrices as a parameter. I need to get it to look like this: I've been using the algorithm package, but ...
Julian Ricardo Beltran Lizaraz's user avatar
0 votes
1 answer
86 views

Pseudocode notation [closed]

In pseudocode, how do you state comparisons and statements? Should I use == and = like in programming languages or should I completely switch to $=$ for comparison and $:=$ for each statement? What ...
Lemonbonbon's user avatar
0 votes
1 answer
195 views

Print apexes/superscript and subscript in quote

I am trying to print apexes and subscript in my pseudocode. I used this code to write it, but it prints it as it is without converting it in math. \begin{quote}\linenumbersep=-5pt \resetlinenumber[1] \...
hellomynameisA's user avatar

1
2 3 4 5