I'm not sure why I get two extra characters at the end of the for loop. Looking at other answers on StackExchange indicates I'm not suppose to use both algorithm and algorithmic and that its better to stick to one. However, removing either does not produce the results I want. Here is the code. \usepackage{setspace} \usepackage{amssymb} \usepackage{amsmath} \usepackage{multicol} \usepackage{algorithm} \usepackage{algorithmic} \usepackage{subcaption} \usepackage{colortbl} \usepackage{xparse} \usepackage{caption} \usepackage{fancyhdr} \usepackage{algpseudocode}  \begin{center} \begin{minipage}{1\textwidth} \begin{algorithm}[H] \caption{Forward calculation for pair HMMs} \begin{algorithmic}  \REQUIRE Set $f^{\mathrm{M}}(0,0)=1 f^{\mathrm{X}}(0,0)=f^{\mathrm{Y}}(0,0)= f^{*}(i,-1) = f^{*}(-1, j) = 0$ \FOR{$i=0, \ldots, n, j=0, \ldots, m \text { except }(0,0)$}  \begin{aligned} f^{\mathrm{M}}(i, j) &amp; = p_{I_{i} O_{j}}\left[a_{MM} (f^{\mathrm{M}}(i-1, j-1))+\\ &amp; \quad \quad \left.a_{XM}\left(f^{\mathrm{X}}(i-1, j-1)\right)+a_{YM}(f^{\mathrm{Y}}(i-1, j-1)\right)\right] \\ f^{\mathrm{X}}(i, j) &amp; = q_{I_{i}}\left[a_{MX} f^{\mathrm{M}}(i-1, j)+a_{XX} f^{\mathrm{X}}(i-1, j)\right] \\ f^{\mathrm{Y}}(i, j) &amp; = q_{O_{j}}\left[a_{MY} f^{\mathrm{M}}(i, j-1)+a_{YY} f^{\mathrm{Y}}(i, j-1)\right]\\ \end{aligned}  \ENDFOR \end{algorithmic} \end{algorithm} \end{minipage} \end{center}
18350
Can you suggest me what is wrong with using return command in algorithms. when I add  \RETURN $C   to my LaTeX document I get   return C =0,   what I need is just return C.  \begin{algorithm}                      % enter the algorithm environment   \caption{ lloyd's kmeans}         \label{alg1}                             \begin{algorithmic}[1]                    % enter the algorithmienvironment     \RETURN{$C$}   \end{algorithmic} \end{algorithm}   I get two extra characters =0. I wonder where its coming from. if it helps,there is  "Missing number, treated as zero",and  Missing = inserted for \ifnum. in the error log generated
65248
I'm getting errors in a matrix equation. When I compile it looks fine, but I'd like to fix them so I don't have to press return for every error at compile time. The code for the equation is:  \begin{equation*}  \begin{bmatrix} U(1,t)  &amp; \cdots &amp; U(n,t) \\  \vdots &amp; \ddots &amp; \vdots \\ O_{n1} &amp; \cdots &amp; O_{nn}  \end{bmatrix} \times \begin{bmatrix} W(1,1)  &amp; \cdots &amp; W(1,n) \\  \vdots &amp; \ddots &amp; \vdots \\  W(n,1) &amp; \cdots &amp; W(n,n)  \end{bmatrix} = \begin{bmatrix}  D(1,t)  &amp; \cdots &amp; D(n,t) \\ \vdots &amp; \ddots &amp; \vdots \\ I_{n1} &amp; \cdots &amp; I_{nn} \end{bmatrix}  \end{equation*}   The errors I'm getting are related to missing $'s inserted.
58979
\documentclass[border=10pt]{standalone} \usepackage{pstricks-add,amsmath,amssymb} \begin{document} \begin{pspicture}[showgrid,arrowinset=0](0,-1)(4,2) \begin{psmatrix}[colsep=.5cm,rowsep=1.2cm] &amp; [name=A]\,\,\,\,\,\,\,\,\,\,\,\,$M_{0,4} \times \mathbb{P}^1 $\\ [name=B]$B$ &amp; [name=C]\,\,\,\,\,\,$M_{0,4}$ \end{psmatrix} \pcline[nodesep=.3]{-&gt;}(B)(C)       \nbput{$\kappa$} \pcline[nodesep=.3]{-&gt;}(A)(C)       \nbput[labelsep=.1]{$\pi$} \naput{\foreach \i in {0.1,0.25,0.4,0.55}{%     \pcline{-&gt;}(\i,-.4)(\i,.45)} \nbput[labelsep=.1]{$\sigma_i$}} \end{pspicture} \end{document}     After see all the answers, done :)   \documentclass[border=10pt]{standalone} \usepackage{pstricks-add,amsmath,amssymb} \begin{document} \begin{psmatrix}[colsep=.5cm,rowsep=1.2cm] &amp; [name=A]\qquad $M_{0,4} \times \mathbb{P}^1 $\\ [name=B]$B$ &amp; [name=C] \quad $M_{0,4}$ \end{psmatrix} \psset{arrowinset=0} \pcline[nodesep=.3]{-&gt;}(B)(C)       \nbput{$\kappa$} \pcline[nodesep=.3]{-&gt;}(A)(C)       \nbput[labelsep=.1]{$\pi$} \naput{\foreach \i in {0.1,0.25,0.4,0.55}{%     \pcline{-&gt;}(\i,-.4)(\i,.45)} \nbput[labelsep=.1]{$\sigma_i$}} \end{document}
39055
I have the following code:  \begin{align} &amp; a+b+c+d+e+f = 15000 &amp; \text{for } a = 1 ... 15  \\ &amp; D_t=  \begin{cases}    \text{equation} , &amp; \text{for } t = 1 ... 10 \\    \text{another equation} , &amp; \text{for } t = 1 ... 10 \\ \end{cases}  \end{align}   This produces the following:   However, I would like the "for" arguments in cases to be aligned to those in the align environment, which would look something like:    I was wondering if there is a way of doing this automatically, rather than using manual spacing. I have tried using arrays, however it didn't seem to solve the issue.  Thank you.
35608
If I try something like \u{i}, I get both the breve and the dot. How can I get it without the dot?
74443
I have a problem with scrarticle (and its option parskip=half), fontenc and algorithm2e:  \documentclass[parskip=half]{scrartcl} \usepackage{fontenc} \usepackage[boxed]{algorithm2e}  \begin{document} \begin{algorithm}     \KwData{test} \end{algorithm} \end{document}   If you compile this document (with pdflatex), then there is no padding between the text and the frame of the algorithm. If you remove parskip=half or \usepackage{fontenc} (or both), then everything is fine.  What is happening here? Did I do anything wrong? How to fix this problem?
109685
In the question , a very nice solution was given for typesetting a column vector with an arbitrary number of rows. I am attempting to modify the code to produce row vectors instead of column vectors. I made the "obvious" change, i.e., substituting the &amp; for the \\ as indicated by the snippet below:  \newcount\colveccount \newcommand*\colvec[1]{         \global\colveccount#1         \begin{pmatrix}         \colvecnext } \def\colvecnext#1{         #1         \global\advance\colveccount-1         \ifnum\colveccount>0                 &amp;                 \expandafter\colvecnext         \else                 \end{pmatrix}         \fi } My modification however fails to compile and the errors, of course, are not very helpful. So my question is, How can I modify the \colvec and \colvecnext macros to produce row vectors?
106174
Some material I'm creating requires output that looks like this:  (note the position of the arrows).    I'm using the following code (with the AMS macros) to generate this, and I'm looking for comments - it works fine, but I'm curious if there's a better/cleaner way to deal with the arrows:  \[   \begin{bmatrix}[rrr|r] 1 &amp; 2 &amp; 0 &amp; -1 \\ 2 &amp; 1 &amp; 1 &amp; 1 \\ -1 &amp; 1 &amp; -1 &amp; -1   \end{bmatrix}   \begin{matrix}[c] ~ \\ \xrightarrow{R_2-2R_1} \\ \xrightarrow{R_3+R_1} \end{matrix}   \begin{bmatrix}[rrr|r] 1 &amp; 2 &amp; 0 &amp; -1 \\ 0 &amp; -3 &amp; 1 &amp; 3 \\ 0 &amp; 3 &amp; -1 &amp; -2 \end{bmatrix}   \begin{matrix}[c] ~ \\ ~ \\ \xrightarrow{R_2+R_3} \end{matrix}   \begin{bmatrix}[rrr|r] 1 &amp; 2 &amp; 0 &amp; -1 \\ 0 &amp; -3 &amp; 1 &amp; 3 \\ 0 &amp; 0 &amp; 0 &amp; 1 \end{bmatrix} \]   I'm using only the standard AMS macros, together with a cute addition to the matrix macros that I found on the Web that allows column specifications within the AMS matrices:  \makeatletter \renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%   \hskip -\arraycolsep   \let\@ifnextchar\new@ifnextchar   \array{#1}} \makeatother
7806
I have simple code:  \documentclass{article}  \usepackage{algorithm}  \usepackage{algpseudocode}  \begin{document}  \begin{algorithm}   \caption{Examples}\label{alg:Examples}   \begin{algorithmic}[1]   \State $X=45$   \State $X=45$   \State $X=45$   \State $X=45$   \State $X=45$    \end{algorithmic} \end{algorithm}          \end{document}     How to put a point after the number of the algorithm? I use chapters in report:  \documentclass[a4paper,12pt]{report}  \usepackage{algorithm}  \usepackage{algpseudocode}  \begin{document}  \chapter{Chapter 1}  \begin{equation} X_2=4 \end{equation}  \begin{algorithm}   \caption{Examples}\label{alg:Examples}   \begin{algorithmic}[1]   \State $X=45$   \State $X=45$   \State $X=45$   \State $X=45$   \State $X=45$    \end{algorithmic} \end{algorithm}  \end{document}     How to change the numbering to take into account the chapters?
90273
Can someone tell me what's wrong with this? because i can't figure out where the missing \right( is.  \begin{equation}  \begin{split} Μ=&amp;-\pi \rho \frac{c^{2}}{4}    \left[c\left(\frac{α}{c}-\frac{1}{2}\right)\ddot{h}+Uc\left(\frac{3}{4}-     \frac{α}{c}\right)\dot{\alpha} +\frac{c^{2}}{4}\left(\frac{9}{8}+      \frac{4α^{2}}{c^{2}}-\frac{4α}{c}\right)\ddot{\alpha} \\  &amp;-\left(\frac{4α}{c}-1\right)U C(k) \left(-\dot{h} +U\alpha + c \left(\frac{3}{4}-\frac{α}{c}\right)\dot{\alpha}\right)\right]  \end{split} \end{equation}
119080
Suppose we have the following code  \documentclass{article} \begin{document} $a=b=c=d=e=f=g=h=i=j=k=l=m=n=o=p=q=r=s=t=u=v=w=x=y=z$ \end{document}   which produces the following result   I want to have an additional equal sign automatically added before symbol s.  UPDATE  The same question about \leq and  $a \leq b \leq c \leq d \leq e \leq f \leq g \leq h \leq i \leq j \leq k \leq l \leq m \leq n \leq o \leq p \leq q \leq r \leq s \leq t \leq u \leq v \leq w \leq x \leq y \leq z$
62360
I used some of the solution proposed in this post:    and my code is as follows:  \documentclass{standalone} \begin{document}  \begin{tabular}{c*{11}{@{\,}c}}       2&amp;:&amp;7&amp;=&amp;0&amp;,&amp;$\overline{2}$&amp;$\overline{8}$&amp;$\overline{5}$&amp;$\overline{7}$&amp; $\overline{1}$&amp;$\overline{4}$       \\       {\color{red} 2} &amp;{\color{red} 0 } &amp; &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp; \\       1 &amp; 4 &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;  \\  \cline{1-2}        &amp; 6&amp; 0 &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;  \\        &amp; 5 &amp; 6 &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;  \\   \cline{2-3}        &amp;  &amp; 4 &amp; 0 &amp;&amp;&amp;&amp;&amp;&amp;&amp;  \\        &amp;  &amp; 3 &amp; 5 &amp;&amp;&amp;&amp;&amp;&amp;&amp;  \\  \cline{3-4}        &amp;  &amp;      &amp; 5 &amp; 0 &amp;&amp;&amp;&amp;&amp;&amp; \\        &amp;  &amp;      &amp; 4 &amp; 9 &amp;&amp;&amp;&amp;&amp;&amp;  \\  \cline{4-5}        &amp;  &amp;      &amp;   &amp; 1 &amp; 0 &amp;&amp;&amp;&amp;&amp; \\        &amp;  &amp;      &amp;   &amp;   &amp; 7 &amp;&amp;&amp;&amp;&amp; \\ \cline{5-6}        &amp;  &amp;      &amp;   &amp;   &amp; 3 &amp; 0 &amp;&amp;&amp;&amp; \\        &amp;  &amp;      &amp;   &amp;   &amp; 2 &amp; 8 &amp;&amp;&amp;&amp; \\  \cline{6-7}        &amp;  &amp;      &amp;   &amp;   &amp;   &amp; { \color{red} 2} &amp;{\color{red} 0} &amp;&amp;&amp;     \end{tabular} \end{document}   The goal is to show the repeating decimal part with overline over the repeating decimals. The code does that, but each decimal is overlined in isolation, but I want a continuous overline!  But that does seem to infer with the mechanics of tabular ...
32739
I am using the algorithmicx package to write an algorithm. However I am using the noend option:  \usepackage[noend]{algpseudocode}   Is there anyway to get vertical lines for each block of code? This question has been answered here:    However, it does not work when using the noend option.  EDIT: I'm looking for something like the algorithms here:
116187
I am writing pseudo code in the algorithmic environment. It is quite long and doesn't fit on one single page. Instead of it continuing on the next page, it is cut off. I tried inserting it into a figure environment, but the problem persists. Is there a solution to have the code continue on the next page?
102851
I am looking for a ConTeXt solution that will allow me to move single letters from the end to the beginning of the line.  LuaLaTeX has   or  packages  Algorithm in Lua
86868
I have two questions. 1. Can I delete the red-colored space? 2. If I use enumerate in proof, QED symbol appears the next line of the end, as above. If I do not want to type manually \qedhere, should I use ntheorem?  \documentclass[a4paper]{article} \usepackage[scale=0.75]{geometry}  \usepackage[english]{babel} \usepackage[utf8x]{inputenc} \usepackage{amsmath} \usepackage{amsthm} \usepackage{amssymb} \usepackage{textcomp} \usepackage{enumitem} \setlist[enumerate]{nosep, label=(\arabic*)}  \theoremstyle{definition} \newtheorem{lem}{Lemma}  \begin{document}  \begin{lem} \begin{enumerate} \item xxxx \item yyyy \end{enumerate} \end{lem} \begin{proof} \begin{enumerate} \item xxxxxxxxxxxxxxxxxxxxxxxxx. xxxxxxxxxxxxxxxxxxxxxxxxx. xxxxxxxxxxxxxxxxxxxxxxxxx. xxxxxxxxxxxxxxxxxxxxxxxxx. xxxxxxxxxxxxxxxxxxxxxxxxx. xxxxxxxxxxxxxxxxxxxxxxxxx.  \item yyyyyyyyyyyy. yyyyyyyyyyyy. yyyyyyyyyyyy. yyyyyyyyyyyy. yyyyyyyyyyyy. yyyyyyyyyyyy. yyyyyyyyyyyy. yyyyyyyyyyyy. yyyyyyyyyyyy. yyyyyyyyyyyy. yyyyyyyyyyyy. yyyyyyyyyyyy. yyyyyyyyyyyy. \end{enumerate} \end{proof}  \end{document}
18022
Well, I liked the idea expressed in the question . But I want it to work in a sightly different way.  I just want to expand the usual _ and ^. How? So that the code escapes from the sup/subscript if there is a space (see exceptions at the bottom):   a_11 + b_123ijk + c_k\ell should be the same as a_{11} + b_{123ijk} + c_{k\ell}. And the same for superscripts: m^qwpoeriu equal to m^{qwpoeriu}.   At this moment, I have this code in my preamble (it helps if you want to write F_\mathrm{max} you can do it like F_|max|), so the solution should't break it  \makeatletter \begingroup\catcode`\_=\active\protected\gdef_{\@ifnextchar|\subtextup\sb}\endgroup \def\subtextup|#1|{\sb{\mathrm{#1}}}  \AtBeginDocument{\catcode`\_=12 \mathcode`\_=32768} \makeatother   Why?  I usually space my code \biggl( a_b \cdot \cos(x - c) = 1 \times \vec v rather than \biggl(a_b\cdot\cos(x-c)=1\times\vec v, because I find it much more easier to read. So this would easily work well for me since in so many times I wouldn't need to write {}. Of course, there are moments where I still need to do it, i.e., \alpha_k\ell + \alpha_{\ell k} = 1.  EDIT: More things. I'm not particularly interested in a_b_c_d + e to be like a_{b_{c_d}} + e (and the same with ^), but I think it would be great if that also worked (which means that the space should escape all the sub/superscripts).  More things, NOT only the space should escape the sub/superscript, also this:   the alternative sup/subscript, i.e.: a_b^c + 1 = 0 should work as a_{b}^{c} + 1 = 0, and a^blk_ijk as a^{blk}_{ijk}, the ending of math $a_bcde$ should be like $a_{bcde}$, and also a closing brace: \frac{1}{a_ijk} equal to \frac{1}{a_{ijk}}.