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,163 questions
1
vote
1
answer
125
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
60
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
66
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
181
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
58
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
73
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
204
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{...
0
votes
0
answers
69
views
Indentation Lines of algpseudocodex does not work in RTL cases
I am trying to create a template for algorithms in Persian. I have the following piece of code, where I am using algpseudocode along with algorithm package. This setup works nicely; however, I would ...
1
vote
1
answer
45
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
60
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
64
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}{$...
0
votes
1
answer
75
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
124
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 ...
1
vote
0
answers
34
views
Missing number, treated as zero in \endif algorithm [duplicate]
Good evening,
I got an error when using algorithm in latex:
\documentclass[oneside,a4paper,14pt]{extreport}
\usepackage{mathtools}
% Font tiếng Việt
\usepackage[T5]{fontenc}
\usepackage[utf8]{inputenc}...
3
votes
1
answer
224
views
How to make a title of procedure over multiple lines with the cryptocode package?
Update: My issue is solved, thanks to Marijn (see the first answer below)! I leave my question below.
I use the package cryptocode to write algorithms, in particular the
\procedure command that I use ...