I want to write a macro for optimisation problems and my current approach is to write a macro, that takes the target function and a list of constraints. The entries are separated by comma, and each entry is of the type "(in)equality / range", e.g.  x_i \geq 0 / i=1,...,n   I got the idea from . However, this does not allow new lines inside an align.  My friend found out to use \pgfplotsforeachungrouped, but now I cannot write &amp; inside the loop. The following code compiles, but does not look nice.  edit: now has entries of type \x/\y.  \documentclass{article} \usepackage{extarrows,pgffor} \usepackage{pgfplots} \begin{document}   \begin{align*}     \pgfplotsforeachungrouped \x/\y in {a/3, b/5, foo/0}{       \x_i : \x = \x \quad i=\y \\     } \end{align*} \end{document}     But if I replace the body of the loop by \x_i : \x &amp;= \x \quad i=\y \\ (just adding the &amp;), I get multiple errors `! Undefined control sequence.  Furthermore, using entry a/{0,\ldots,5} does not work as expected. It only takes the 0.  Also I might wish to put the range of my variable inside \tag, or similar. Tying this, I get another Undefined control sequence for `\y¸.   So how can I align these lines inside the loop? solved in answer of Steven B. Segletes How can I have more complex values in the entries? How can I place the second part of an entry inside \tag*{}?   Maybe-helpful-link: I don't understand , so I can't tell, whether the idea helps, but it seems to go in the direction.
121412
I'm trying to use the tikz package's foreach command in a tabular environment. I know that it is not really suited for doing this, but how would I be able to make the following command work (I think, it is obvious what it should do, and I know that there are some difficulties regarding the textbf command as well):  \newcommand{\myTable}[1]{     \begin{tabular}{p{0.35\textwidth}|p{0.65\textwidth}}         \hline         Headline 1 &amp; Headline 2 \\         \foreach \lhs/\rhs in {#1} {             \textbf{\lhs} &amp; \rhs \\         }         \hline     \end{tabular} }   MWE:  \documentclass{article} \usepackage{tikz}  \newcommand{\myTable}[1]{     \begin{tabular}{p{0.35\textwidth}|p{0.65\textwidth}}         \hline         Headline 1 &amp; Headline 2 \\         \foreach \lhs/\rhs in {#1} {             \textbf{\lhs} &amp; \rhs \\         }         \hline     \end{tabular} }  \begin{document} \myTable{{Title 1}/{Description 1}, {Title 2}/{Description 2}} \end{document}
28876
I'm trying to define two commands \bal and \eal instead of inserting \begin{align} and \end{align} in my document, but in the code below, I'll get some errors. What is wrong with it?    \documentclass{article} \usepackage{amsmath} \makeatletter  \newcommand{\bal}{%  \begingroup  \align% \@ifstar{\nonumber}{}%  }  \newcommand{\eal}{\endalign\endgroup} \makeatother \begin{document} \bal* x=y \eal ‎\end{document}
38916
I have the following code:  \documentclass[11pt]{article} \usepackage[a4paper]{geometry} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{tikz} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture}[node distance = 0.5cm, auto] \node (0) {Block 0}; \node (1) [below= of 0.south] {Block 1}; \node (2) [below= of 1.south] {Block 2}; \end{tikzpicture} \end{document}   It prints this:    I tried to do the same with pgf loop, but don't know how to decrease the counter:  \foreach \x in {0,...,2} {   \ifnum\x=0\relax       \node (\x) {Block \x};   \else       %\prev=\x - 1 &lt;- ???       \node (\x) [below= of \prev.south] {Block \x};   \fi }
97394
I'm displayed three lines on a pgfplot. I want to show a marker for the slope of each line and the difference in height between lines.     I'm showing the slopes by adding triangles under the lines  (at a manual position) and placing an annotation inside the triangle (at a manual position). I'm showing the difference between the height of the lines by adding a brace manually as well.   How can I place the braces on the plot and anchor them at a certain point on each line? The triangles can be added at the end of each line declaration, but doing it like this is ok. The braces are put in place manually, which is not sustainable as I create more plots.   I want to avoid using xshift, yshiftand manual adjustment to put the braces,traingles and annotations in the right place. How can I do this?      \documentclass{article} \usepackage{pgfplots}  \pgfplotsset{compat=1.9}  \begin{document}   \begin{tikzpicture}[scale=0.45,trim axis left, trim axis right]     \begin{axis}[ylabel={$\hat{S(4)}$},xlabel={$S{^*}_{breakeven}$},ylabel style={rotate=-90},domain=1:25, legend style={legend pos=north west,font=\scriptsize}, legend cell align=left]  \addplot+[samples=200,mark=none]                                    {6.26 + 0.28*x} coordinate[pos=0.5](x) coordinate[pos=0.9] (y) (x)-| (y) node [midway,xshift=-0.6cm,yshift=0.3cm] {\footnotesize $Slope X$};;  \addplot+[samples=200,mark=none, dotted, thick]             {2.66 + 0.28*x}  coordinate[pos=0.3](a) coordinate[pos=0.6] (b) (a)-| (b) node [midway,xshift=-0.5cm,yshift=0.2cm] {\footnotesize $Slope 1$};  \draw [decorate,decoration={brace,amplitude=5pt,raise=4pt},xshift=4pt]  (225,107) -- (225,73)  node [midway,xshift=0.6cm] {\footnotesize $\beta_1$};  \end{axis} \end{tikzpicture} \end{document}
43240
This question is a follow up to my :  Is it possible to use &gt; and &lt; to pipe opening and closing braces on each side of a cell's content? To be more specific, what I want is to define the following column:  \newcolumntype{P}{&gt;{\leavevmode\kern-\tabcolsep\bfseries\parbox[t]{\hsize}{}X&lt;{}}}   I want a column type that automatically embraces the cell content in a \parbox.  I enclose a short MNWE:  \documentclass[table]{article} \usepackage{lmodern, microtype, xcolor, tabularx, tabulary}  \begin{document}  \begin{tabularx}{0.5\columnwidth}{&gt;{\raggedright\arraybackslash\leavevmode\kern-\tabcolsep\parbox[t]{\hsize}{ }X&lt;{}}XX&lt;{\leavevmode\kern-\tabcolsep\raggedleft\arraybackslash}}  \rowcolor{lightgray}All this testing is not so funny&amp;test&amp;test\\\hline testing, testing and even more testing &amp;test&amp;test\\ \rowcolor{lightgray}I want to write a noce table in a simple way&amp;test&amp;test\\ \end{tabularx}  \end{document}
39390
I'm trying to add this expression to my work:   I understand that the best way to achieve this is using the alignat environment within the amsmath package, so I tried the following:  \begin{alignat*}{3} m &amp;&amp; \text{módulo} &amp;&amp; m&gt;0\\ a &amp;&amp; \text{multiplicador} &amp;&amp; 0&lt;a&lt;m\\ c &amp;&amp; \text{constante aditiva} &amp;&amp; 0\leq c&lt;m\\ x_0 &amp;&amp; \text{valor inicial} &amp;&amp; 0\leq x_0 &lt;m \end{alignat*}   But the spacing I'm getting is really weird, I have read the amsmath documentation but I can't figure out what's the problem.  This was I'm getting:   My version is in spanish and I'm using polyglossia, but I don't think that's relevant. Anyway I'm using xelatex, and the book class.  I also wanted to know if there is a way to write the whole equation in the same environment with the middle text, or do I need to make another math environment for the centered equation at the end.
42644
I have more than 10,000 rows of data I need to do some calculations on one column of the data. I have made the calculation in one cell and now need to fill the formula for the calculation and all the cells.  Usually I just select the cells using the keyboard and then press the Ctrl+D to fill the cells. However, now I have to do this repeatedly, and it is difficult to keep on selecting 5000 rows each file. Is there a simpler way where I can just specify the range using the keyboard? Perhaps even have a macro since all of the files have a fixed length  Also, since I have difficulty in using the mouse because of medical reasons and therefore I have not tested  which involves clicking on a very small fill handle. Maybe there is a parallel solution to this using the keyboard or maybe I can create a macro which will automatically click on a fill handle of a selected cell - please advise if there is a way.
37681
This code works correctly:  \documentclass{article} \usepackage{tikz} \usetikzlibrary{positioning,calc} \begin{document}  \begin{tikzpicture}   \tikzset{     every picture/.prefix style={       execute at begin picture=\shorthandoff{;}     }   }   \def\names{{"1", "2"}}   \foreach \i in {0,1} {%     \ifnum\i=0\relax       \node (\i) [draw] {\pgfmathparse{\names[\i]}\pgfmathresult};     \else       \pgfmathparse{int(\i-1)}       \node (\i) [draw,right= 1cm of \pgfmathresult]             {\pgfmathparse{\names[\i]}\pgfmathresult};       \draw[dotted] ($(\pgfmathresult.south east) !.5! (\i.south west)$)             -- +(0,1cm);   \fi } \end{tikzpicture} \end{document}   But when I add  \usepackage[utf8]{inputenc} \usepackage[german]{babel}   to the preamble, it starts giving an error:  ! Argument of \language@active@arg" has an extra }. &lt;inserted text&gt;                  \par  l.25 }   the same for russian. It is somehow related to the quotes in the array:   \def\names{{"1", "2"}}   I tried the tricks, shown here for the french, but they don't work.
15675
Is this just a bit of historical cruft left over from the 1950s or is there some reason syntactically why multi-expression bodies of (if) forms require (progn)? Why can't you wrap the multiple expressions in a set of parentheses like with (let):     (if some-cond      ((exp1) (exp2) (exp3)) ; multi exp "then"      (exp4)) ; single exp "else"   It appears it would be trivial to write a macro to test each body to see first if it is a list and then if it is, if its first element is also a list (and thus not a function invocation) and then to wrap its subcomponents inside a (progn) accordingly.
2783
Related (but not the same):         Earlier today I asked a question about aligning equations in an enumerate environment and got an answer that seemed to work for the example I gave, but it turns out I wasn't really specific enough for my problem.  I'm using align* environments, often as the only part of a list item. (If you're wondering why I'm not using more words to introduce the align*, these are mostly homework solutions where most of the work is algebra, etc.)  Here's my code and what it makes (above the middle line):  \begin{enumerate}   \item \begin{align*}     x^2 + y^2 &amp;= x^2 + (iy)^2 \\               &amp;= (x + iy) (x - iy)   \end{align*}   \item \begin{align*}     \frac{1}{n^2-4} &amp;= \frac14 \frac{4}{(n-2)(n+2)} \\                     &amp;= \frac14 \left( \frac{1}{n-2}-\frac{1}{n+2} \right)   \end{align*} \end{enumerate}     I'm trying to make the baseline of the first line of the align* environment the same as the number's baseline—I want the first line of the align* to have the same vertical position (centered horizontally in the same way) relative to its number as in the second half of my picture. (Side question: why is there so much space before the align* starts?)
73544
I want to write an algorithm in a table for my paper. I tried to write it, but I want to write ''While'' instead of ''for'' in this algorithm. How can I do it? And I want to put the table everywhere in the text.  \begin{algorithm}     \caption{ OMP Algorithm     }     \label{alg1}     \begin{latin}         \begin{algorithmic}[1]             \REQUIRE Decomposition of signal ‎$x‎$‎             \STATE\textbf{Input:}  signal ‎$‎x \in \mathcal{R}^{m}‎$‎, Dictionary ‎$‎‎\mathcal{G}‎ ‎\in ‎\mathcal{R}^{m \times n‎‎}‎$‎,‎‎$‎\hat{x}=‎\emptyset‎$‎ ‎‎             \STATE  \textbf{Output:}  Decomposed signal $‎\hat{x}_{est}‎‎$ ‎after ‎$‎k‎$‎ ‎‎iteration, Residual ‎‎$‎R^{(k)}‎$‎‎       \STATE ‎\textbf{Initialization} ‎$‎‎R^{(0)}=x‎‎$‎             \STATE \textbf{for i=1:k do}‎             \STATE ‎$‎l‎=\displaystyle{arg\max_{l=1,\dots ,l} |‎\langle ‎g_l,R^{(i)} ‎‎\rangle‎‎|‎}$‎‎‎ ‎\qquad‎ ‎finding ‎the ‎atom ‎in ‎dictionary ‎‎$‎\mathcal{G}‎$‎ ‎‎with ‎maximum ‎correlation ‎with ‎residual.‎             \STATE ‎$‎R^{(i+1)}=R{(i)}-a_l g_l^{(i)}‎‎$‎             \STATE ‎$\hat{x}‎=‎\hat{x}‎+‎\langle ‎R^{(i)},g_{l}^{(i)} ‎‎\rangle ‎g_{l}^{(i)}‎‎$‎       \STATE \‏‎textbf{end}‎         \end{algorithmic}     \end{latin} \end{‎algorithm}
105905
After reading a question on "",  I have a code like this that refers to the inequalities    \documentclass{article} \usepackage{mathtools} \usepackage{amssymb} \usepackage{MnSymbol} \usepackage{tikz} \usepackage{pgfplots} \usetikzlibrary{intersections} \usetikzlibrary{patterns}  \makeatletter \newcommand{\pgfplotsdrawaxis}{\pgfplots@draw@axis} \makeatother \pgfplotsset{only axis on top/.style={axis on top=false, after end axis/.code={              \pgfplotsset{axis line style=opaque, ticklabel style=opaque, tick style=opaque,                           grid=none}\pgfplotsdrawaxis}}}  \newcommand{\drawge}{-- (rel axis cs:1,0) -- (rel axis cs:1,1) -- (rel axis cs:0,1) \closedcycle} \newcommand{\drawle}{-- (rel axis cs:1,1) -- (rel axis cs:1,0) -- (rel axis cs:0,0) \closedcycle}  \begin{document} \begin{figure}[ht] \centering \begin{tikzpicture} \begin{axis}[axis line style=thin, axis x line=center, axis y line=center, ymin=-7, ymax=7, xmin=-7, xmax=7, xlabel=\(x\), ylabel=\(y\), grid=minor] \addplot[name path global=line1, pattern=north west lines, color=blue!50, thick, domain=-7:7]{3*x-5}; \addplot[name path global=line2, pattern=north west lines, color=blue!50, thick, domain=-7:7]{6-2*x}; \addplot [draw=none, pattern=northeast lines, pattern color=blue!40, domain=-7:7]{3*x-5} \drawle; \addplot [draw=none, pattern=northeast lines, pattern color=blue!40, domain=-7:7]{6-2*x} \drawge; \end{axis} \end{tikzpicture} \end{figure}   \end{document}   which looks like    I want it to look like   , where the graph is filled only where all the inequalities hold true. NOTE the two graphs are entirely different problems. I only want the style, not the question.  However, the code for the latter image uses intersections:  \begin{figure}[ht] \centering \begin{tikzpicture}     \begin{axis}[axis line style=thin,     axis x line=center,     axis y line=center,     ymin=-6, ymax=7, xmin=-6, xmax=11, xlabel=\(x\), ylabel=\(y\), grid=minor]     \addplot[name path global=line1, color=blue!50, thick, domain=-5:10]{5/3-x/3};     \addplot[name path global=line2, color=blue!50, thick, domain=-5:10]{x/5-10/7};     \addplot[name path global=line3, color=blue!50, thick, domain=-5:10]{6*x+10};     \fill[name intersections={of=line1 and line2,by=point1}, name intersections={of=line1 and line3,by=point2}, name intersections={of=line2 and line3,by=point3}][very thick, pattern=northeast lines, draw=blue!60, pattern color=blue!30!cyan](point1)--(point2)--(point3)--(point1);     \end{axis} \end{tikzpicture} \end{figure}   The first image has only one intersecting point, hence I cannot use this method. I also don't want other areas shaded- only the final areas where the lines intersect. Is there a way around it without to find the points in which the lines intersect the border of the grid, meaning I have to manually compute the points?  EDIT: added the inequalities for the graph.
115683
Let me describe the data setup. A line has been provided as an array of coordinate pairs, one for each vertex. This array is variable in size, anywhere from 2 to 200 coordinate pairs per line. What I am trying to wrap my mind around is the best way to create these lines. Arcpy and ArcObjects are both viable options, but ArcObjects is preferred due to its speed (generally).   I have brainstormed a few methods, but they fall short for some reason or another:  1) I could use the  with arcpy to create polylines and then Copy Features, but the resulting geometry would not have any of the attribution necessary to identify said points.  2) I could use , but this only works with one pair of point, and I require something much more robust.  The long and short is that I require a method that can create a polyline from arrays and maintain a schema for data that I have created in a table. One idea I have is to create said table and schema, and then somehow create the polyline and copy its shape property to the output table, porting over the ID and whatever other attribution is needed. How can I go about creating the polyline's shape property without resorting to an intermediate shapefile? Or, if there is a better method that comes to mind, please share it with me.  Update This code seems to work!  IFeatureClass fClass = gpUtil.OpenFeatureClassFromString(path); IFeatureCursor cursor = fClass.Insert(true); IFeatureBuffer buffer = fClass.CreateFeatureBuffer();  &lt;snip...&gt;  string[] nodearray = a.Split(';'); foreach (string i in nodearray) {     query.WhereClause = "\"PNT_ID\" = '" + i+"'";     Console.WriteLine(query.WhereClause.ToString());     ICursor search = table.Search(query, false);     IRow row = search.NextRow();     float x = float.Parse(row.get_Value(2).ToString());     float y = float.Parse(row.get_Value(3).ToString());     int id = int.Parse(row.get_Value(1).ToString());     point.X = x;     point.Y = y;     point.ID = id;     point.SpatialReference = sRef;     pCollection.AddPoint(point, ref Missing, ref Missing);  } IGeometry5 polygeo = (IGeometry5)pCollection; buffer.set_Value(1, polygeo); buffer.set_Value(2, wayid); cursor.InsertFeature(buffer);
15089
Is there a way to insert a blank line between two equations in align environment?  From what I understand a blank line is interpreted as \par and \par is not allowed in align. Can I disable this "feature" in align environment?  Reason:  I like my code to be in 80 column format. So when I hit M-q (fill-paragraph) without blank lines, the code looks like this:  \begin{align}   \min \sum_{k \in K} \sum_{(i,j) \in A} c_{ij} x_{ij}^k + \sum_{(i,j)     \in A} f_{ij} y_{ij} \\ \sum_{j \in V_i^+} x_{ij}^k - \sum_{j \in     V_i^-} x_{ji}^k = \begin{cases} d^k &amp; \text{si } i = O(k) \\ -d^k     &amp; \text{si } i = D(k) \\ 0 &amp; \text{sinon} \end{cases} &amp; \quad   \quad \forall i \in V, \; \forall k \in K \\ \sum_{k \in K} x_{ij}^k   \le u_{ij} y_{ij} &amp; \quad \quad \forall (i,j) \in A \end{align}   instead of this:  \begin{align}   \min \sum_{k \in K} \sum_{(i,j) \in A} c_{ij} x_{ij}^k + \sum_{(i,j)     \in A} f_{ij} y_{ij} \\    \sum_{j \in V_i^+} x_{ij}^k - \sum_{j \in V_i^-} x_{ji}^k   = \begin{cases} d^k &amp; \text{si } i = O(k) \\ -d^k &amp; \text{si } i =     D(k) \\ 0 &amp; \text{sinon} \end{cases} &amp; \quad \quad \forall i \in   V, \; \forall k \in K \\    \sum_{k \in K} x_{ij}^k \le u_{ij} y_{ij} &amp; \quad \quad \forall   (i,j) \in A \end{align}   which is easier (for me) to read and edit.
10375
I have a very long equation that must be separated into two lines, and it has several pairs of nesting \left \right delimiters. Unfortunately, it seems that they need to be on the same line in order for them to work.  Also I'm using the align environment because I need the aligning functionality. Is there a way to have the size of delimiters automatically adjusted over multiple lines?
53280
I want to show the derivation of a formula where I encounter long formulae. Unfortunately the derivation is very complex, so I have to show some intermediate steps.  My problem is, that I want to mix the behaviour of multline with align. The first line should be aligned left and the whole rest should be aligned right with respect to the longest line. This block should be aligned at the =.  At the moment, I use the align environment. But in this case, the first line is still aligned left to the $ of the other lines.  Important note: I don't like magic numbers. So I prefer solutions which are completely automatic.    My approach so far:  \documentclass{scrartcl} % Kodierung \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} % Sprache (neue deutsche Rechtschreibung) \usepackage[ngerman]{babel} % Mathematik \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb}  \begin{document}     \begin{align}         (a+b+c+d+e+f) \\ % aligned left         % the following block should be aligned right         &amp;= a+b+c+d+e+f+g+h+i+j+k+l+m+n\\     \begin{split}         &amp;= a+b+c+d+e+f+g+h+i+j+k+l+m+n \\         &amp; \quad +o+p+q+r+s+t+u+v+w+x+y+z+1+2+3+4     \end{split}\\         &amp;= a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p     \end{align} \end{document}
12367
For  I wanted to define a shortcut for creating a matrix inside a tikzpicture. As a minimal example, consider  \newcommand\mymatrix[1]{     \begin{tikzpicture}         \matrix[matrix of math nodes] {#1};     \end{tikzpicture}% }   which would then be used as  \mymatrix{     a &amp; b \\     e &amp; f \\ }   But LaTeX complains about Package pgfbasematrix Error: Single ampersand used with wrong catcode at the line with the closing brace of \amatrix{}. Why does it do that and how can I avoid it?