Questions tagged [algorithms]
{algorithms} is about the presentation, numbering, and layout of algorithms or pseudocode in documents. Popular packages are algorithms, {algorithmicx}, {algorithm2e} and {listings}. For questions about the specific package, use the appropriate tag instead.
1,165 questions
3
votes
0
answers
38
views
Prevent extra line spacing due to end in algorithms [duplicate]
\documentclass{article}
\usepackage{amsmath}
\usepackage[nothing, ruled]{algorithm}
\usepackage[noend]{algpseudocode}
\let\Algorithm\algorithm
\renewcommand\thealgorithm{}
\newcommand{\setalgolineno}[...
0
votes
0
answers
30
views
Issue with latex code when writing algorithm statement [duplicate]
I'm trying to write an algorithm. I don't understand what's wrong at the very last equation (line 4:), there is =0 in the end for some reason after [:,perm]. Below is the exact reproducible code along ...
6
votes
1
answer
170
views
Change Text Color of Certain Lines in Algorithmic Environment
What I'm trying to do:
I'm trying to change the text color of specific lines to highlight them in an algorithmic environment (using algpseudocodex package).
\documentclass[12pt]{article}
\usepackage{...
1
vote
1
answer
168
views
How do I make multiple require line in latex
I am writing the pseudocode with latex.I need to find a way to make multiple lines of require.Basically, I tried to use
\\
but it does not work. Please help me do that. Here is my code.
\begin{...
0
votes
0
answers
68
views
Displaybreak for algorithms
I have the following problem. I have a relatively long pseudocode, and when I have text before it, either 1) there is a lot of white space, or 2) the text on the previous page is stretched out, or the ...
1
vote
1
answer
76
views
Problem with an Algorithm [closed]
I wrote this code:
\begin{algorithm}
\caption{SBX Operator}\label{alg:sbx}
\begin{algorithmic}
\State $\eta_{SBX} \gets 5$
\For{i=1:L}
\State sample $u \in [0,1]$
...
3
votes
1
answer
196
views
I want to Draw Prim's and Dijkstra's algorithm for a technical Paper in Latex Using Tkiz package
I am very new to LaTeX and its surrounding infrastructure. I am trying to write a technical paper on LaTeX using the TikZ package. However, I am finding it difficult to draw the images in the format I ...
1
vote
2
answers
71
views
Alternate Lines Side-by-Side in Algorithm
I am writing an algorithm where some parts slightly change depending on the variant, but are mostly the same. I have found a very clear way to do this is with side by side lines, colour coded for the ...
3
votes
1
answer
80
views
Aligning equation numbers correctly in an algorithm
I am writing an article in which I use the algorithm environment. When I put a numbered equation in the algorithm (sorry computer science people), the equation number is not aligned properly. Very ...
4
votes
1
answer
268
views
cleveref + algorithm + algcompatible: regression from texlive 2024 to 2025?
I've noticed an apparent regression when using cleveref to reference lines of algorithms with the combination of algorithm and algcompatible. Below is an example:
\documentclass{article}
\usepackage{...
1
vote
1
answer
58
views
How to add (negative) vertical spacing to the body of algorithm float automatically?
For my course material, I "abuse" the algorithm floats, since my knowledge of LaTeX is too poor to do this "better". I hope you can forgive me for that 😉. (Actually, I'm all doing ...
0
votes
1
answer
70
views
Undefined control sequence in Agorithm Latex
can you help me fix the error, also please help me make two algorithm consistent in format (with line number) for the second algorithm I don't know why it render number 0 after update lambda.
I'm so ...
1
vote
1
answer
76
views
LaTeX algorithm indentation in color
I am using the algorithmic environment in LaTeX and want to color both the line numbers and the corresponding content of specific lines. Here's the code snippet I'm working on:
\Procedure{\writetxn}{$...
1
vote
2
answers
106
views
Dotted box around algorithm
We need the box with dotted rules around the algorithm. I tried using
\usepackage[boxruled]{algorithm2e}. The rule comes as solid rule instead of dotted what I required.
Can you please check and ...
2
votes
1
answer
167
views
How to customize step numbering in the algorithmic package to prefix each line with "Step" in LaTeX?
I am currently working with the algorithmic package and need to modify the output of an algorithm such that each line starts with the word Step followed by the step number. The goal is to have the ...