How do I write a simple if-elseif protocol in Latex?Write pseudo code in latexhow to insert protocol in...
Help to reproduce a tcolorbox with a decoration
French for 'It must be my imagination'?
Is creating your own "experiment" considered cheating during a physics exam?
function to receive a character input and return date format (with incorrect input)
Solving a linear system of reciprocals.
Minimum value of 4 digit number divided by sum of its digits
How to pronounce 'C++' in Spanish
You look catfish vs You look like a catfish
How to back up a running remote server?
Python: pythonic way to find last position in string that does not match regex
How do I deal with a coworker that keeps asking to make small superficial changes to a report, and it is seriously triggering my anxiety?
A Note on N!
Feels like I am getting dragged in office politics
Please, smoke with good manners
TikZ how to make supply and demand arrows for nodes?
How to delegate to implementing class
Can fracking help reduce CO2?
Can not tell colimits from limits
Inner for loop when run in background in bash spawns new bash process
How can I place the product on a social media post better?
Is DC-to-DC (24 V to 12 V) buck conversion typically more efficient than AC-to-DC (110 V to 12 V) conversion?
Why is current rating for multicore cable lower than single core with the same cross section?
How to creep the reader out with what seems like a normal person?
Are Boeing 737-800’s grounded?
How do I write a simple if-elseif protocol in Latex?
Write pseudo code in latexhow to insert protocol in Lyx?how to write algorithm in latex?How can i write the pseudo code Algorithm in Latex?How to write a procedure in Latex?How can make a protocol in latex?How to write algorithm like this in latexhow to write the algorithm in latexAlgorithm: ELSEIF problemProtocol in latex longer then one page?
I've tried using algorithm, algorithmic, etc.. but I can't seem to find what I need. I want something similar to this:

This is the closest I got using tcolorbox and align:
begin{tcolorbox}[colframe=white,
colback=white,
coltitle=black,
fonttitle=normalfont,
adjusted title= underline{textbf{Protocol $hat{Q_1}$}} (for undecided process $i$ at time $m$):]
begin{align*}
&textbf{if} quad K_i good(exists 0) &textbf{then} quad decide_i(0) \
&textbf{elseif} quad m=t+1 cup same_i(m,m-1) &textbf{then} quad decide_i(1)
end{align*}
end{tcolorbox}

I would like to get rid of the extra space between the title and the code, as well as make everything align as in the example above.
tabularx algorithms
New contributor
Ariel Livshits is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I've tried using algorithm, algorithmic, etc.. but I can't seem to find what I need. I want something similar to this:

This is the closest I got using tcolorbox and align:
begin{tcolorbox}[colframe=white,
colback=white,
coltitle=black,
fonttitle=normalfont,
adjusted title= underline{textbf{Protocol $hat{Q_1}$}} (for undecided process $i$ at time $m$):]
begin{align*}
&textbf{if} quad K_i good(exists 0) &textbf{then} quad decide_i(0) \
&textbf{elseif} quad m=t+1 cup same_i(m,m-1) &textbf{then} quad decide_i(1)
end{align*}
end{tcolorbox}

I would like to get rid of the extra space between the title and the code, as well as make everything align as in the example above.
tabularx algorithms
New contributor
Ariel Livshits is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Welcome to TeX.SE! Please show us the code you have tried so far!
– Kurt
2 hours ago
@Kurt, added the code to post.
– Ariel Livshits
1 hour ago
add a comment |
I've tried using algorithm, algorithmic, etc.. but I can't seem to find what I need. I want something similar to this:

This is the closest I got using tcolorbox and align:
begin{tcolorbox}[colframe=white,
colback=white,
coltitle=black,
fonttitle=normalfont,
adjusted title= underline{textbf{Protocol $hat{Q_1}$}} (for undecided process $i$ at time $m$):]
begin{align*}
&textbf{if} quad K_i good(exists 0) &textbf{then} quad decide_i(0) \
&textbf{elseif} quad m=t+1 cup same_i(m,m-1) &textbf{then} quad decide_i(1)
end{align*}
end{tcolorbox}

I would like to get rid of the extra space between the title and the code, as well as make everything align as in the example above.
tabularx algorithms
New contributor
Ariel Livshits is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I've tried using algorithm, algorithmic, etc.. but I can't seem to find what I need. I want something similar to this:

This is the closest I got using tcolorbox and align:
begin{tcolorbox}[colframe=white,
colback=white,
coltitle=black,
fonttitle=normalfont,
adjusted title= underline{textbf{Protocol $hat{Q_1}$}} (for undecided process $i$ at time $m$):]
begin{align*}
&textbf{if} quad K_i good(exists 0) &textbf{then} quad decide_i(0) \
&textbf{elseif} quad m=t+1 cup same_i(m,m-1) &textbf{then} quad decide_i(1)
end{align*}
end{tcolorbox}

I would like to get rid of the extra space between the title and the code, as well as make everything align as in the example above.
tabularx algorithms
tabularx algorithms
New contributor
Ariel Livshits is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Ariel Livshits is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 1 hour ago
Ariel Livshits
New contributor
Ariel Livshits is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 2 hours ago
Ariel LivshitsAriel Livshits
112
112
New contributor
Ariel Livshits is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Ariel Livshits is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Ariel Livshits is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Welcome to TeX.SE! Please show us the code you have tried so far!
– Kurt
2 hours ago
@Kurt, added the code to post.
– Ariel Livshits
1 hour ago
add a comment |
Welcome to TeX.SE! Please show us the code you have tried so far!
– Kurt
2 hours ago
@Kurt, added the code to post.
– Ariel Livshits
1 hour ago
Welcome to TeX.SE! Please show us the code you have tried so far!
– Kurt
2 hours ago
Welcome to TeX.SE! Please show us the code you have tried so far!
– Kurt
2 hours ago
@Kurt, added the code to post.
– Ariel Livshits
1 hour ago
@Kurt, added the code to post.
– Ariel Livshits
1 hour ago
add a comment |
2 Answers
2
active
oldest
votes
If you want to keep the tcolorbox you could use tabularx instead of the align environment:
documentclass{article}
usepackage{tabularx}
usepackage{tcolorbox}
usepackage{amsmath}
begin{document}
begin{tcolorbox}[colframe=white,
colback=white,
coltitle=black,
fonttitle=normalfont,
adjusted title= underline{textbf{Protocol $hat{Q_1}$}} (for undecided process $i$ at time $m$):]
begin{tabularx}{linewidth}{lXll}
textbf{if} & $K_i good(exists 0)$ &textbf{then} & $text{decide}_i(0)$ \
textbf{elseif} & $m=t+1 cup text{same}_i(m,m-1)$ &textbf{then} & $text{decide}_i(1)$
end{tabularx}
end{tcolorbox}
end{document}
Alternatively, you might want to have a look into the packages designed for pseudocode such as algorithm2e, algorithmicx, algorithm, algpseudocode...
add a comment |
Not sure how general this is.
documentclass{article}
usepackage{amsmath}
usepackage{array}
newcommand{fun}[1]{mathsf{#1}}
begin{document}
noindent
begin{tabular}{@{hspace{3em}}>{bfseries}ll>{bfseries}ll@{}}
multicolumn{4}{@{}l@{}}{%
underline{textbf{Protocol $hat{Q_1}$}} (for undecided process $i$ at time $m$):%
} \[2ex]
if & $K_i fun{good}(exists 0)$ & then & $fun{decide}_i(0)$ \
elseif & $m=t+1 cup fun{same}_i(m,m-1)$ & then & $fun{decide}_i(1)$ \
end{tabular}
end{document}

add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Ariel Livshits is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f488088%2fhow-do-i-write-a-simple-if-elseif-protocol-in-latex%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you want to keep the tcolorbox you could use tabularx instead of the align environment:
documentclass{article}
usepackage{tabularx}
usepackage{tcolorbox}
usepackage{amsmath}
begin{document}
begin{tcolorbox}[colframe=white,
colback=white,
coltitle=black,
fonttitle=normalfont,
adjusted title= underline{textbf{Protocol $hat{Q_1}$}} (for undecided process $i$ at time $m$):]
begin{tabularx}{linewidth}{lXll}
textbf{if} & $K_i good(exists 0)$ &textbf{then} & $text{decide}_i(0)$ \
textbf{elseif} & $m=t+1 cup text{same}_i(m,m-1)$ &textbf{then} & $text{decide}_i(1)$
end{tabularx}
end{tcolorbox}
end{document}
Alternatively, you might want to have a look into the packages designed for pseudocode such as algorithm2e, algorithmicx, algorithm, algpseudocode...
add a comment |
If you want to keep the tcolorbox you could use tabularx instead of the align environment:
documentclass{article}
usepackage{tabularx}
usepackage{tcolorbox}
usepackage{amsmath}
begin{document}
begin{tcolorbox}[colframe=white,
colback=white,
coltitle=black,
fonttitle=normalfont,
adjusted title= underline{textbf{Protocol $hat{Q_1}$}} (for undecided process $i$ at time $m$):]
begin{tabularx}{linewidth}{lXll}
textbf{if} & $K_i good(exists 0)$ &textbf{then} & $text{decide}_i(0)$ \
textbf{elseif} & $m=t+1 cup text{same}_i(m,m-1)$ &textbf{then} & $text{decide}_i(1)$
end{tabularx}
end{tcolorbox}
end{document}
Alternatively, you might want to have a look into the packages designed for pseudocode such as algorithm2e, algorithmicx, algorithm, algpseudocode...
add a comment |
If you want to keep the tcolorbox you could use tabularx instead of the align environment:
documentclass{article}
usepackage{tabularx}
usepackage{tcolorbox}
usepackage{amsmath}
begin{document}
begin{tcolorbox}[colframe=white,
colback=white,
coltitle=black,
fonttitle=normalfont,
adjusted title= underline{textbf{Protocol $hat{Q_1}$}} (for undecided process $i$ at time $m$):]
begin{tabularx}{linewidth}{lXll}
textbf{if} & $K_i good(exists 0)$ &textbf{then} & $text{decide}_i(0)$ \
textbf{elseif} & $m=t+1 cup text{same}_i(m,m-1)$ &textbf{then} & $text{decide}_i(1)$
end{tabularx}
end{tcolorbox}
end{document}
Alternatively, you might want to have a look into the packages designed for pseudocode such as algorithm2e, algorithmicx, algorithm, algpseudocode...
If you want to keep the tcolorbox you could use tabularx instead of the align environment:
documentclass{article}
usepackage{tabularx}
usepackage{tcolorbox}
usepackage{amsmath}
begin{document}
begin{tcolorbox}[colframe=white,
colback=white,
coltitle=black,
fonttitle=normalfont,
adjusted title= underline{textbf{Protocol $hat{Q_1}$}} (for undecided process $i$ at time $m$):]
begin{tabularx}{linewidth}{lXll}
textbf{if} & $K_i good(exists 0)$ &textbf{then} & $text{decide}_i(0)$ \
textbf{elseif} & $m=t+1 cup text{same}_i(m,m-1)$ &textbf{then} & $text{decide}_i(1)$
end{tabularx}
end{tcolorbox}
end{document}
Alternatively, you might want to have a look into the packages designed for pseudocode such as algorithm2e, algorithmicx, algorithm, algpseudocode...
answered 49 mins ago
leandriisleandriis
12.1k1833
12.1k1833
add a comment |
add a comment |
Not sure how general this is.
documentclass{article}
usepackage{amsmath}
usepackage{array}
newcommand{fun}[1]{mathsf{#1}}
begin{document}
noindent
begin{tabular}{@{hspace{3em}}>{bfseries}ll>{bfseries}ll@{}}
multicolumn{4}{@{}l@{}}{%
underline{textbf{Protocol $hat{Q_1}$}} (for undecided process $i$ at time $m$):%
} \[2ex]
if & $K_i fun{good}(exists 0)$ & then & $fun{decide}_i(0)$ \
elseif & $m=t+1 cup fun{same}_i(m,m-1)$ & then & $fun{decide}_i(1)$ \
end{tabular}
end{document}

add a comment |
Not sure how general this is.
documentclass{article}
usepackage{amsmath}
usepackage{array}
newcommand{fun}[1]{mathsf{#1}}
begin{document}
noindent
begin{tabular}{@{hspace{3em}}>{bfseries}ll>{bfseries}ll@{}}
multicolumn{4}{@{}l@{}}{%
underline{textbf{Protocol $hat{Q_1}$}} (for undecided process $i$ at time $m$):%
} \[2ex]
if & $K_i fun{good}(exists 0)$ & then & $fun{decide}_i(0)$ \
elseif & $m=t+1 cup fun{same}_i(m,m-1)$ & then & $fun{decide}_i(1)$ \
end{tabular}
end{document}

add a comment |
Not sure how general this is.
documentclass{article}
usepackage{amsmath}
usepackage{array}
newcommand{fun}[1]{mathsf{#1}}
begin{document}
noindent
begin{tabular}{@{hspace{3em}}>{bfseries}ll>{bfseries}ll@{}}
multicolumn{4}{@{}l@{}}{%
underline{textbf{Protocol $hat{Q_1}$}} (for undecided process $i$ at time $m$):%
} \[2ex]
if & $K_i fun{good}(exists 0)$ & then & $fun{decide}_i(0)$ \
elseif & $m=t+1 cup fun{same}_i(m,m-1)$ & then & $fun{decide}_i(1)$ \
end{tabular}
end{document}

Not sure how general this is.
documentclass{article}
usepackage{amsmath}
usepackage{array}
newcommand{fun}[1]{mathsf{#1}}
begin{document}
noindent
begin{tabular}{@{hspace{3em}}>{bfseries}ll>{bfseries}ll@{}}
multicolumn{4}{@{}l@{}}{%
underline{textbf{Protocol $hat{Q_1}$}} (for undecided process $i$ at time $m$):%
} \[2ex]
if & $K_i fun{good}(exists 0)$ & then & $fun{decide}_i(0)$ \
elseif & $m=t+1 cup fun{same}_i(m,m-1)$ & then & $fun{decide}_i(1)$ \
end{tabular}
end{document}

answered 41 mins ago
egregegreg
737k8919393268
737k8919393268
add a comment |
add a comment |
Ariel Livshits is a new contributor. Be nice, and check out our Code of Conduct.
Ariel Livshits is a new contributor. Be nice, and check out our Code of Conduct.
Ariel Livshits is a new contributor. Be nice, and check out our Code of Conduct.
Ariel Livshits is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f488088%2fhow-do-i-write-a-simple-if-elseif-protocol-in-latex%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Welcome to TeX.SE! Please show us the code you have tried so far!
– Kurt
2 hours ago
@Kurt, added the code to post.
– Ariel Livshits
1 hour ago