\begin{algorithm}
\caption{Sinkhorn's algorithm}
\begin{algorithmic}
\WHILE{ $\| B(u_{k}, v_{k})1 - \mu \| + \| B(u_{k}, v_{k})^{T} 1 - \nu \| \ge \epsilon'$ }
\IF {$k \text{ mod } 2 = 0$}
\STATE $u_{k+1} = u_{k} + ln \left( \frac{\mu}{B(u_{k},v_{k})\mathrm{1}} \right)$
\STATE $v_{k+1} = v_{k}$
\ELSE
\STATE $v_{k+1} = v_{k} + ln \left( \frac{\nu}{B(u_{k},v_{k})^{T} \mathrm{1}} \right) $
\STATE $u_{k+1} = u_{k}$
\ENDIF
\STATE $k = k+1$
\end{algorithmic}
\end{algorithm}
This code doesn't work do you know why ?
Thanks and regards.
\ENDWHILE should be used to indicate the end of the loop.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{amsmath}
\begin{document}
\begin{algorithm}
\caption{Sinkhorn's algorithm}
\begin{algorithmic}
\WHILE{ $\| B(u_{k}, v_{k})1 - \mu \| + \| B(u_{k}, v_{k})^{T} 1 - \nu \| \ge \epsilon'$ }
\IF {$k \text{ mod } 2 = 0$}
\STATE $u_{k+1} = u_{k} + ln \left( \frac{\mu}{B(u_{k},v_{k})\mathrm{1}} \right)$
\STATE $v_{k+1} = v_{k}$
\ELSE
\STATE $v_{k+1} = v_{k} + ln \left( \frac{\nu}{B(u_{k},v_{k})^{T} \mathrm{1}} \right) $
\STATE $u_{k+1} = u_{k}$
\ENDIF
\STATE $k = k+1$
\ENDWHILE
\end{algorithmic}
\end{algorithm}
\end{document}
Related
I want to emulate this in LaTeX code as an equation.
\usepackage{spalign}
\[
\spalignsys{
\text{Maximizar} \hspace{4mm} z=c_1x_1+c_2x_2+\dots+c_nx_n ;
\text{Sujeto a:} ;
\hspace{4mm} a_{11}x_1+a_{12}x_2+\dots+a_{1n}x_n \leq b_1;
x_1,x_2,\dots,x_n \geq 0 }
\]
You can use the same technique as in https://tex.stackexchange.com/a/587258/36296 :
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\left\{\begin{array}{lc}
\text{Maximizar} & z=c_1x_1+c_2x_2+\dots+c_nx_n\\
\text{Sujeto a:}& \\
&a_{11}x_1+a_{12}x_2+\dots+a_{1n}x_n \leq b_1\\
& x+1+2+3\\
\end{array}\right.
\]
\end{document}
I want to add another line of italic text below 'Surbiton high school'. When I add another line it just overlaps on top of what is there, instead of underneath my A-level description.
I am very new to all of this and am using a template to create my CV. Any help much appreciated!
I have included a screenshot of the CV
%-------------------------
% Resume in Latex
% Author : Jake Gutierrez
% Based off of: https://github.com/sb2nov/resume
% License : MIT
%------------------------
\documentclass[letterpaper,11pt]{article}
\usepackage{latexsym}
\usepackage[empty]{fullpage}
\usepackage{titlesec}
\usepackage{marvosym}
\usepackage[usenames,dvipsnames]{color}
\usepackage{verbatim}
\usepackage{enumitem}
\usepackage[hidelinks]{hyperref}
\usepackage{fancyhdr}
\usepackage[english]{babel}
\usepackage{tabularx}
\usepackage{contour}
\usepackage{ulem}
\input{glyphtounicode}
%----------FONT OPTIONS----------
% sans-serif
% \usepackage[sfdefault]{FiraSans}
% \usepackage[sfdefault]{roboto}
% \usepackage[sfdefault]{noto-sans}
% \usepackage[default]{sourcesanspro}
% serif
% \usepackage{CormorantGaramond}
% \usepackage{charter}
\pagestyle{fancy}
\fancyhf{} % clear all header and footer fields
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
% Adjust margins
\addtolength{\oddsidemargin}{-0.5in}
\addtolength{\evensidemargin}{-0.5in}
\addtolength{\textwidth}{1in}
\addtolength{\topmargin}{-.5in}
\addtolength{\textheight}{1.0in}
\urlstyle{same}
\raggedbottom
\raggedright
\setlength{\tabcolsep}{0in}
% Sections formatting
\titleformat{\section}{
\vspace{-4pt}\scshape\raggedright\large
}{}{0em}{}[\color{black}\titlerule \vspace{-5pt}]
% Ensure that generate pdf is machine readable/ATS parsable
\pdfgentounicode=1
%-------------------------
% Custom commands
\newcommand{\resumeItem}[1]{
\item\small{
{#1 \vspace{-2pt}}
}
}
\newcommand{\resumeSubheading}[4]{
\vspace{-2pt}\item
\begin{tabular*}{0.97\textwidth}[t]{l#{\extracolsep{\fill}}r}
\textbf{#1} & #2 \\
\textit{\small#3} & \textit{\small #4} \\
\end{tabular*}\vspace{-7pt}
}
\newcommand{\resumeSubSubheading}[2]{
\vspace{-2pt}\item
\begin{tabular*}{0.97\textwidth}[t]{l#{\extracolsep{\fill}}r}
\text{#1} & #2 \\
\end{tabular*}\vspace{-7pt}
}
\newcommand{\resumeProjectHeading}[2]{
\item
\begin{tabular*}{0.97\textwidth}{l#{\extracolsep{\fill}}r}
\small#1 & #2 \\
\end{tabular*}\vspace{-7pt}
}
\renewcommand{\ULdepth}{3pt}
\contourlength{0.8pt}
\newcommand{\myuline}[1]{%
\uline{\phantom{#1}}%
\llap{\contour{white}{#1}}%
}
\newcommand{\resumeSubItem}[1]{\resumeItem{#1}\vspace{-4pt}}
\renewcommand\labelitemii{$\vcenter{\hbox{\tiny$\bullet$}}$}
\newcommand{\resumeSubHeadingListStart}{\begin{itemize}[leftmargin=0.15in, label={}]}
\newcommand{\resumeSubHeadingListEnd}{\end{itemize}}
\newcommand{\resumeItemListStart}{\begin{itemize}}
\newcommand{\resumeItemListEnd}{\end{itemize}\vspace{-5pt}}
%-------------------------------------------
%%%%%% RESUME STARTS HERE %%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%-----------EDUCATION-----------
\section{Education}
\resumeSubHeadingListStart
\resumeSubheading
{The University of Sussex}{Brighton, UK}
{Bachelor of Science in Economics - First Class Honours}{September 2018 -- June 2021}
\begin{itemize}
\item podcast
\end{itemize}
\resumeSubheading
{Surbiton High School}{London, UK}
{A-level Qualifications in Economics A, Mathematics A, Physics C}{September 2014 -- June 2016}
\resumeSubHeadingListEnd
Leave an empty line to start a new paragraph and then add whatever text you want (and \end{document} is missing again ...):
%-------------------------
% Resume in Latex
% Author : Jake Gutierrez
% Based off of: https://github.com/sb2nov/resume
% License : MIT
%------------------------
\documentclass[letterpaper,11pt]{article}
\usepackage{latexsym}
\usepackage[empty]{fullpage}
\usepackage{titlesec}
\usepackage{marvosym}
\usepackage[usenames,dvipsnames]{color}
\usepackage{verbatim}
\usepackage{enumitem}
\usepackage[hidelinks]{hyperref}
\usepackage{fancyhdr}
\usepackage[english]{babel}
\usepackage{tabularx}
\usepackage{contour}
\usepackage{ulem}
\input{glyphtounicode}
%----------FONT OPTIONS----------
% sans-serif
% \usepackage[sfdefault]{FiraSans}
% \usepackage[sfdefault]{roboto}
% \usepackage[sfdefault]{noto-sans}
% \usepackage[default]{sourcesanspro}
% serif
% \usepackage{CormorantGaramond}
% \usepackage{charter}
\pagestyle{fancy}
\fancyhf{} % clear all header and footer fields
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
% Adjust margins
\addtolength{\oddsidemargin}{-0.5in}
\addtolength{\evensidemargin}{-0.5in}
\addtolength{\textwidth}{1in}
\addtolength{\topmargin}{-.5in}
\addtolength{\textheight}{1.0in}
\urlstyle{same}
\raggedbottom
\raggedright
\setlength{\tabcolsep}{0in}
% Sections formatting
\titleformat{\section}{
\vspace{-4pt}\scshape\raggedright\large
}{}{0em}{}[\color{black}\titlerule \vspace{-5pt}]
% Ensure that generate pdf is machine readable/ATS parsable
\pdfgentounicode=1
%-------------------------
% Custom commands
\newcommand{\resumeItem}[1]{
\item\small{
{#1 \vspace{-2pt}}
}
}
\newcommand{\resumeSubheading}[4]{
\vspace{-2pt}\item
\begin{tabular*}{0.97\textwidth}[t]{l#{\extracolsep{\fill}}r}
\textbf{#1} & #2 \\
\textit{\small#3} & \textit{\small #4} \\
\end{tabular*}\vspace{-7pt}
}
\newcommand{\resumeSubSubheading}[2]{
\vspace{-2pt}\item
\begin{tabular*}{0.97\textwidth}[t]{l#{\extracolsep{\fill}}r}
\text{#1} & #2 \\
\end{tabular*}\vspace{-7pt}
}
\newcommand{\resumeProjectHeading}[2]{
\item
\begin{tabular*}{0.97\textwidth}{l#{\extracolsep{\fill}}r}
\small#1 & #2 \\
\end{tabular*}\vspace{-7pt}
}
\renewcommand{\ULdepth}{3pt}
\contourlength{0.8pt}
\newcommand{\myuline}[1]{%
\uline{\phantom{#1}}%
\llap{\contour{white}{#1}}%
}
\newcommand{\resumeSubItem}[1]{\resumeItem{#1}\vspace{-4pt}}
\renewcommand\labelitemii{$\vcenter{\hbox{\tiny$\bullet$}}$}
\newcommand{\resumeSubHeadingListStart}{\begin{itemize}[leftmargin=0.15in, label={}]}
\newcommand{\resumeSubHeadingListEnd}{\end{itemize}}
\newcommand{\resumeItemListStart}{\begin{itemize}}
\newcommand{\resumeItemListEnd}{\end{itemize}\vspace{-5pt}}
%-------------------------------------------
%%%%%% RESUME STARTS HERE %%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%-----------EDUCATION-----------
\section{Education}
\resumeSubHeadingListStart
\resumeSubheading
{The University of Sussex}{Brighton, UK}
{Bachelor of Science in Economics - First Class Honours}{September 2018 -- June 2021}
\begin{itemize}
\item podcast
\end{itemize}
\resumeSubheading
{Surbiton High School}{London, UK}
{A-level Qualifications in Economics A, Mathematics A, Physics C}{September 2014 -- June 2016}
\textit{a new line}
\resumeSubHeadingListEnd
\end{document}
In the minipage environment with listing and figure I'd like to have three separate captions a, b, c evenly as the picture below:
But my try with this minimal code results an untidy captions as below:
\documentclass[11pt]{article}
\usepackage{listings}
\usepackage{amsmath}
\usepackage{graphicx}
%\usepackage{caption}
\begin{document}
\begin{figure}[h!]
\noindent\begin{minipage}{0.3\textwidth}
\begin{lstlisting}[]
while(a < 0){
a++;
}
\end{lstlisting}
\caption{C program}
\end{minipage}%
\noindent\begin{minipage}{0.45\textwidth}
\begin{align*}
&F_1(a, b) \leftarrow a \le 0 \\
&F_2(a, b) \leftarrow F_1(a, b) \\
\end{align*}
\caption{Automata}
\end{minipage}%
\noindent\begin{minipage}{0.3\textwidth}
\includegraphics[scale=0.2]{example-image-a}
\caption{Relation}
\end{minipage}%
\caption{overal blablablablablabla caption}
\end{figure}
\end{document}
How can I get rid of Figure keyword and get a, b, c caption in the same level?
You can [b]ottom align your minipages:
\documentclass[11pt]{article}
\usepackage{listings}
\usepackage{amsmath}
\usepackage{graphicx}
%\usepackage{caption}
\begin{document}
\begin{figure}[h!]
\noindent\begin{minipage}[b]{0.3\textwidth}
\begin{lstlisting}[]
while(a < 0){
a++;
}
\end{lstlisting}
\caption{C program}
\end{minipage}%
\noindent\begin{minipage}[b]{0.45\textwidth}
\begin{align*}
&F_1(a, b) \leftarrow a \le 0 \\
&F_2(a, b) \leftarrow F_1(a, b) \\
\end{align*}
\caption{Automata}
\end{minipage}%
\noindent\begin{minipage}[b]{0.3\textwidth}
\includegraphics[scale=0.2]{example-image-a}
\caption{Relation}
\end{minipage}%
\end{figure}
\end{document}
The same technique works also with subfigures:
\documentclass[11pt]{article}
\usepackage{listings}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}[h!]
\noindent\begin{subfigure}[b]{0.3\textwidth}
\begin{lstlisting}[]
while(a < 0){
a++;
}
\end{lstlisting}
\caption{C program}
\end{subfigure}%
\noindent\begin{subfigure}[b]{0.45\textwidth}
\begin{align*}
&F_1(a, b) \leftarrow a \le 0 \\
&F_2(a, b) \leftarrow F_1(a, b) \\
\end{align*}
\caption{Automata}
\end{subfigure}%
\noindent\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[scale=0.2]{example-image-a}
\caption{Relation}
\end{subfigure}%
\caption{text}
\end{figure}
\end{document}
Consider the following class diagram:
\documentclass{article}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{empheq}
\usepackage{mdframed}
\usepackage{booktabs}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{color}
\usepackage{psfrag}
\usepackage{pgfplots}
\usepackage{bm}
\usepackage{tikz}
\usepackage{tikz-uml}
\begin{document}
\begin{figure}[h!]
\centering
\begin{tikzpicture}
\umlclass[]{Class1}
{
}
{
}
\umlinterface[y=4]{Class2}{}
{
+ createDocument(doc: str) : str \\
+ resolveDocument(id: str) : str \\
+ updateDocument(doc: str) : str \\
+ deleteDocument(id: str) : str \\
+ createStatusList(sl: str) \\
+ resolveStatusList(id: str) \\
+ updateStatusList(sl: str) \\
+ deleteStatusList(id: str)
}
\umlclass[x=-2,y=-3]{Class33333333333333333333333}{}{}
\umlclass[x=3,y=-3]{Class4}{}{}
\umlinherit{Class1}{Class2}
\umlaggreg[geometry=|-|]{Class1}{Class33333333333333333333333}
\umlaggreg[geometry=|-|]{Class1}{Class4}
\end{tikzpicture}
\end{figure}
\end{document}
Since Class3 is bigger in size I had to add a unit for the x coordinate of Class2 to keep some space between the two. Is this the correct approach? How can I get even space between classes by not playing with coordinates? Every time a class changes in size I often need to redefine many coords. Also, how to fix the alignment of the two classes in respect of Class 1?
You can use relative positioning from the TikZ positioning library:
\documentclass{article}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{empheq}
\usepackage{mdframed}
\usepackage{booktabs}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{color}
\usepackage{psfrag}
\usepackage{pgfplots}
\usepackage{bm}
\usepackage{tikz}
\usepackage{tikz-uml}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}[h!]
\centering
\begin{tikzpicture}
\umlinterface{Class2}{}
{
+ createDocument(doc: str) : str \\
+ resolveDocument(id: str) : str \\
+ updateDocument(doc: str) : str \\
+ deleteDocument(id: str) : str \\
+ createStatusList(sl: str) \\
+ resolveStatusList(id: str) \\
+ updateStatusList(sl: str) \\
+ deleteStatusList(id: str)
}
\umlclass[below=1cm of Class2]{Class1}
{
}
{
}
\umlclass[below left=2cm and 0.5cm of Class1]{Class33333333333333333333333}{}{}
\umlclass[below right=2cm and 0.5cm of Class1]{Class4}{}{}
\umlinherit{Class1}{Class2}
\umlaggreg[geometry=|-|]{Class1}{Class33333333333333333333333}
\umlaggreg[geometry=|-|]{Class1}{Class4}
\end{tikzpicture}
\end{figure}
\end{document}
I am trying to get aligned equations within a box in rmarkdown. I am knitting to pdf.
The reason the box is necessary is because the YAML metadata I use automatically left-aligns all the text, but I want the equations centered.
Here is my rmarkdown code. As you can see when you run it, the equations are centered but the second set of = signs are not aligned across the two lines.
Any help much appreciated.
---
title: "Aligning equations in a box"
output:
pdf_document: default
html_document: null
word_document: null
toc: yes
linestretch: 1.3
classoption: fleqn
header-includes:
- \setlength{\mathindent}{0pt}
- \setlength\parindent{0pt}
---
\setlength{\abovedisplayskip}{-15pt}
\setlength{\belowdisplayskip}{1pt}
\setlength{\abovedisplayshortskip}{1pt}
\setlength{\belowdisplayshortskip}{1pt}
```{r global_options, include=FALSE, echo = FALSE}
knitr::opts_chunk$set(fig.width=12, fig.height=8, fig.path='Figs/',
echo=FALSE, warning=FALSE, message=FALSE, dev = 'pdf')
```
These words are automatically left-aligned by the YAML meta-data above so a box is necessary to centre equations.
### Equation 11.6
\[\large
\makebox[\linewidth]{$\displaystyle
\begin{aligned}
\text{when}\ PT &= 0:logit\ h(t_{j})\ &= [\alpha_{7}D_{7} + \alpha_{8}D_{8} + \cdots + \alpha_{12}D_{12}]\\
\text{when}\ PT &= 1:logit\ h(t_{j})\ &= [\alpha_{7}D_{7} + \alpha_{8}D_{8} + \cdots + \alpha_{12}D_{12}] + \beta_{1}
\end{aligned}
$}
\]
Not sure I understand, but is it necessary to have a big space between? If not, you can just remove the &,
\[\large
\makebox[\linewidth]{$\displaystyle
\begin{aligned}
\text{when}\ PT =& 0:logit\ h(t_{j})\ = [\alpha_{7}D_{7} + \alpha_{8}D_{8} + \cdots + \alpha_{12}D_{12}]\\
\text{when}\ PT =& 1:logit\ h(t_{j})\ = [\alpha_{7}D_{7} + \alpha_{8}D_{8} + \cdots + \alpha_{12}D_{12}] + \beta_{1}
\end{aligned}
$}
\]
this gives
If you want a space you could use something like \qquad or \quad
\[\large
\makebox[\linewidth]{$\displaystyle
\begin{aligned}
\text{when}\ PT =& 0:logit\ h(t_{j})\ \qquad= [\alpha_{7}D_{7} + \alpha_{8}D_{8} + \cdots + \alpha_{12}D_{12}]\\
\text{when}\ PT =& 1:logit\ h(t_{j})\ \qquad= [\alpha_{7}D_{7} + \alpha_{8}D_{8} + \cdots + \alpha_{12}D_{12}] + \beta_{1}
\end{aligned}
$}
\]
which gives me
EDIT:
Answering the question in your comment. Wrap the blocks in between two &.
\[\large
\makebox[\linewidth]{$\displaystyle
\begin{aligned}
\text{whenmoretext}\ PT &= 0:logit\ h(t_{j})\ & &= [\alpha_{7}D_{7} + \alpha_{8}D_{8} + \cdots + \alpha_{12}D_{12}]\\
\text{when}\ PT &= 1:logit\ h(t_{j})\ & &= [\alpha_{7}D_{7} + \alpha_{8}D_{8} + \cdots + \alpha_{12}D_{12}] + \beta_{1}
\end{aligned}
$}
\]