I want to typesetting the words as below:  My code: \documentclass[b5paper,UTF8]{article} \usepackage{graphicx}                 \usepackage{geometry}                \usepackage{fancyhdr} \usepackage{times}  \geometry{left=2cm,right=2cm,top=2.8cm,bottom=2.5cm}  \begin{document} \noindent \textsf{\textbf{4. Avoid inefficient patterns, construct efficient patterns}}  4.1. Rule-based programming can be both very fast and very slow, depending on how you build your structures and rules, but in practice it is easier to inadvertently make  it slow. It will be slow for rules which force the pattern-matcher to make many a  priory doomed matching attempts, for example by under-utilizing each run of the pattern- matcher through a long list (expression). Sorting elements is a good example:  list \/ \/ . \{ left\_\_\_ , x \_ , y \_ , right \_\_\_ \}\/ \; x $&gt;$ y \:  $&gt;$ \{ left, y, x, right \} - has a cubic complexity in the size of the list.  \end{document}  However, the main problem is  list \/ \/ . \{ left\_\_\_ , x \_ , y \_ , right \_\_\_ \}\/ \; x $&gt;$ y \:  $&gt;$ \{ left, y, x, right \} - has a cubic complexity in the size of the list.
121110
I am very new to LaTeX and I am writing my thesis. In a chapter, I want to show my codes, which are in Mathematica.   I use the listings package as follows:  \documentclass{article}   \usepackage{listings}   \begin{document}   \lstset{language=Mathematica}    \begin{lstlisting}   Do[i^j,{i,1,10},{j,1,10}]   \end{lstlisting}    \end{document}   However, the output is much different to what the code looks like in the Mathematica IDE (even if I use other languages in \lstset{language=&lt;name&gt;}):    I read some questions on the site but, in some of them, the font or color of the codes were not the same. Could you please help me to display something like the picture below in LaTeX?  If it is important, I am using the BiDi package.
4846
There's something wrong with this code:  \newenvironment{Tbl} {\begin{tabularx}{\textwidth}{|l|X|} \hline} {\end{tabularx}}   but this is fine:  \newenvironment{Tbl} {\begin{tabular}{|l|l|} \hline} {\end{tabular}}   Why? And how can I get the first to work?  Here is the full LaTeX file:  \documentclass[a4paper, 12pt]{article} \usepackage{tabularx}  \newenvironment{Tbl} {\begin{tabularx}{\textwidth}{|l|X|} \hline} {\end{tabularx}}  \begin{document}  \begin{Tbl} \end{Tbl}  \end{document}      latex test.tex   produces:  This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)  %&amp;-line parsing enabled. entering extended mode (./test.tex LaTeX2e &lt;2005/12/01&gt; Babel &lt;v3.8h&gt; and hyphenation patterns for english, usenglishmax, dumylang, noh yphenation, arabic, basque, bulgarian, coptic, welsh, czech, slovak, german, ng erman, danish, esperanto, spanish, catalan, galician, estonian, farsi, finnish,  french, greek, monogreek, ancientgreek, croatian, hungarian, interlingua, ibyc us, indonesian, icelandic, italian, latin, mongolian, dutch, norsk, polish, por tuguese, pinyin, romanian, russian, slovenian, uppersorbian, serbian, swedish,  turkish, ukenglish, ukrainian, loaded. (/usr/share/texmf/tex/latex/base/article.cls Document Class: article 2005/09/16 v1.4f Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size12.clo)) (/usr/share/texmf/tex/latex/tools/tabularx.sty (/usr/share/texmf/tex/latex/tools/array.sty)) (./test.aux)) Runaway argument?  \par  ! File ended while scanning use of \TX@get@body. &lt;inserted text&gt;                  \par  &lt;*&gt; test.tex  ?
97148
When working with large documents, or even across multiple (smaller) documents, I often find that I forget which typographical consistencies I should stick to.  With TeX being inherently consistent in the way it does things, most things are kept organized without the user even knowing about it. Additionally, using a customized documentclass (like , for example) or packages (like  and , to name two) improves on this consistency by user's choice. Sometimes, however, you are left to your own devices and have to do things manually. Of course, the latter could also stem from not knowing that a package exists to do the job for you, or because you'd rather have more control over the placement/use of a certain things without having it automated or globally set.  To this extent, I though this would be a good place to ask the question: "Which tools/techniques do you use to maintain consistency within your document?"  Sure, the question sounds broad. Many answers are scattered across this site and elsewhere (like the  or Bringhurst's ). I was hoping to contain this diverse knowledge base in one location on TeX.SX (similar to what was done for  and ).  Here are some examples of useful (manual) tips/tricks:   The TeX Book mentions (p 25) the use of ties (~) in the context of Thor's "A SHORT STORY" when typesetting Mr.~Drofnats:     A good typist will use ties within names...   provides a good example of when/why to use either \emph or \textit. The contents of  has some very relevant manual application of consistencies, including:   Put a tilde before references or citations, e.g., Jie~\cite{habit06}. Differentiate between text comma and math comma, e.g., type for $x=a$, $b$, or~$c$ instead of for $x=a,b$, or $c$. Write ellipsis using \ldots instead of three dots.  The  also provides an interesting list of "do's and dont's".   Any more?
100297
I wanted to type an equation in LaTeX. But it is too long to fit into one line. It involves big arrays with many columns so I cannot split it. I wanted to reduce the font size so that it can fit in one line. However, \small doesn't work in the equation environment.
116083
I tried to use a header and footer layout I found here on this website. But I have some problems with changing the code to what I want. I want the pagenumbering to be like page x of y in the footer. It would be nice with this layout (just with page x of y instead of just page x):  \cfoot{\parbox{\textwidth}{\hrulefill\kern-0.6ex\raisebox{-0.5ex}{$\Bigl[$\makebox[2em][c]{\thepage}$\Bigr]$}\kern-0.5ex\hrulefill}}   But the pagenumbering is in the header and there aren't a space between the letters and the numbers as you can see in my minimal work example:  \documentclass[12pt,a4paper]{book}%generelt \usepackage{fancyhdr} \pagestyle{fancy} \fancyhf{} % clear all headers and footers \renewcommand{\headrulewidth}{0pt} % remove rule between header and text \fancyhead[LE, RO]{\thepage of \pageref{LastPage}} % put page number in left header on even pages,                             % right header on odd pages \fancyhead[RE]{\nouppercase{\leftmark}} % remove uppercase on chapter title \renewcommand{\chaptermark}[1]{\markboth{#1}{}} % remove "Chapter N." prefi \usepackage{lastpage}   Another problem is that I would like to have a chapter numbering in the header. The design is really nice, but I would like to have the chapter number too, just like "CHAnumber| name of the chapter".  Is it possible to make this two changes? And how? Thank you very much for help!
122171
I'm participating in a programming contest and we are allowed to prepare a team reference document which must not exceed 25 pages. Typically we will prepare many code templates and this year I'm trying to use latex to typeset these C++ codes and I want to know what's the best way to do that.  Some requirements:   Since there is a page length limit I want to typeset my codes as compact as possible. I want to have the C++ codes syntax highlighted. If it is possible to generate a compact table of content in front, it would be best.
113133
I am having problems displaying algorithms. The wrapping is really ugly and I can't, for the life of me, find a fix that doesn't involve manually tweaking the hell out of everything, to the point that I might as well scrap the crappy algorithm packages and write everything out in TeX.  Is there any way to properly indent the following  \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm}    \caption{My pseudo code.} \begin{algorithmic}[1]    \While{this line is sooooooooooo long and boring and too much for algorithmic to handle}       \State look at this state, this state is just too long for algorithmic to display it properly        \While{again this line is sooooooooooo long and boring and too much for algorithmic too handle}          \State look at this state again, this state is just too long for algorithmic to handle, I'm just going to switch to Word       \EndWhile    \EndWhile \end{algorithmic} \end{algorithm} \end{document}​     so that the output is similar to
2773
I have a multi-line equation that I want to have matching sized parentheses. The advice I read online was to use \left( equation \right. \\ left. rest-of-equation \right) . However, this syntax leaves first half of the equation unaware of what is in the second half. For example, if you include a square root term after the break, the second parenthesis will be larger than the opening parenthesis. When you are using the aligned environment to split a long equation this can look somewhat offputting.    Compare the top equation to the bottom one. The parentheses match in size for the bottom equation, but the left hand parentheses for the top one is  noticeably smaller.  Top Code:   \begin{aligned}[t]   \gamma_{\text{u}} + \frac{1}{108}   \left(57\gamma_{\text{er}} \right. &amp;+  38\gamma_{\text{se}}\\ &amp; {}\pm  \left.\sqrt{2601 \gamma_{\text{er}}^2 + 3648  \gamma_{\text{er}}\gamma_{\text{se}} + 1444 \gamma_{\text{se}}^2}  \right)   \end{aligned}   Bottom Code:  \begin{aligned}[t] \gamma_{\text{u}} + \frac{1}{16} \left(9\gamma_{\text{er}}  +  6\gamma_{\text{se}} \pm  \sqrt{49 \gamma_{\text{er}}^2 + 76 \gamma_{\text{er}}\gamma_{\text{se}} + 36 \gamma_{\text{se}}^2} \right) \end{aligned}
28788
The following code gives me an error:  \documentclass[12pt]{article} \usepackage[margin=2cm]{geometry} \usepackage [english]{babel} \usepackage{amsmath, amssymb} \usepackage{enumitem, array} \begin{document} {\begin{minipage}[t]{\textwidth} \begin{enumerate}[label=(\roman*)] {\setlength\itemindent{10pt}\item  \begin{equation*} \begin{array}{&gt;{\centering\arraybackslash}m{1.5cm}&gt;{\centering\arraybackslash}m{1.5cm}&gt;{\centering\arraybackslash}m{1.5cm}&gt;{\centering\arraybackslash}m{1.5cm}&gt;{\centering\arraybackslash}m{1.5cm}}  \hline x &amp; l_{[x]} &amp; d_{[x]} &amp; l_{x+1} &amp; \mathring{e}_{[x]} \\ \hline \end{array} \end{equation*}} \end{enumerate} \end{minipage}} \end{document}   Note: for various reasons, I have to keep minipage there. For some reason, this code gives me an error when it compiles. It gives the following output:     The errors either say there is a } missing or a $ missing. My eyes don't see such a thing!
106053
I have been using LaTeX for quite some time, but I find the math writing to be a bit frustrating. It seems to take me a relatively long time to code-write long math expressions, and sometimes it's hard to see where { start and end.  I am interested in writing as fast as possible.  Is code-typing each symbol really the fastest way? Is there any good program (in the spirit of Word's MathType) that enables producing math expressions by button clicking, that you recommend?
10108
There is nothing worse than coming across a website with paragraphs that span the width of your screen resolution. They are usually so hard to read, I don't even bother.  A lot of web designers use generic grid and column systems, but I don't feel these have been optimised for readability, they are more of design guide on general aesthetics.  I guess it comes down to words per line. Are the rules that apply to print media the same for screen media?  Are there any type of guidelines to help me size the width of paragraphs on the screen?  I want to take into consideration:   Major web font faces (i.e. Arial, Verdana, Georgia, Times) A range font sizes (i.e. 8px-24px) Space between columns
18254
this TeX-source  \documentclass[a4paper,12pt]{book} \usepackage[usenames,dvipsnames,svgnames,table,x11names]{xcolor} \usepackage{fancyhdr} \pagestyle{fancy} \fancyhead[LO,RE]{} \fancyhead[LE,RO]{{\large{}\color{DarkRed}\rightmark}} \fancyfoot[C]{\thepage} \fancyfoot[LE,RO]{\color{DarkRed}\large{}\leftmark} \fancyfoot[LO,RE]{xxx} \renewcommand{\headrulewidth}{0.14mm} \renewcommand{\footrulewidth}{0.14mm} \setlength\headheight{6mm}  \begin{document} \markboth{A}{B}  Yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda ...  \end{document}   when compiled with XeLaTeX, will cause this output:    as you can see, the red A is not properly aligned with the rest of the footer. naturally i first assumed that was because of the font size, but, surprisingly, changing  \fancyfoot[LE,RO]{\color{DarkRed}\large{}\leftmark}   to  \fancyfoot[LE,RO]{\large{}\leftmark}   gives me not only (naturally) a black A, but also a properly aligned one:    any hints why that should be so? any fixes?
71223
\documentclass[12pt,a4paper]{report} \usepackage[british]{babel} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=false]{microtype} \DisableLigatures[f]{encoding = T1} \microtypecontext{spacing=nonfrench} \usepackage{geometry} \geometry{     left=2cm,     right=2cm,     top=2cm,     bottom=2cm,     bindingoffset=0mm } \begin{document}     \noindent Note that the word “values” is not hyphenated as “val-ues”.     \begin{enumerate}         \item it could list every single one of them so that one knows that there are multiple mode values in a data set.         \item it could list every single one of them so that one knows that there are multiple mode val- ues in a data set.     \end{enumerate}     \noindent\rule{\textwidth}{0.1mm}\\      \noindent In the following example, the word “determined” is not hyphenated.     \vspace{3mm}      \noindent In a statistical hypothesis test, the \textbf{probability of an alpha error} (error probability) is determined. If the latter is low, $H_0$ can be rejected in favour of $H_1$!     \vspace{3mm}      \noindent In a statistical hypothesis test, the \textbf{probability of an alpha error} (error probability) is deter- mined. If the latter is low, $H_0$ can be rejected in favour of $H_1$! \end{document}
40764
I am developing some tables on LaTeX environment and I am having some troubles with the spacing. Originally, I was able to generate the tables using the standard \begin{table}, but then I tried to add some features, as the capability to break the table if it is too long (using longtable) the issue appears. I also want to align numbers by decimal point and center, reason why I use siunitx package. The problem is on the last column, which had a width almost the double than the others. If I specify the column width, the problem "disappear", but I'm really interested in the possibility of automatically generate the width of the table.  The code is the following:  \documentclass[paper=a4, fontsize=11pt]{scrartcl} \usepackage[english]{babel} \usepackage{siunitx} \usepackage{longtable} \usepackage{booktabs}  \begin{document} \begin{longtable}{l*{4}{S}} % no problem specifying the column width\begin{longtable}{l*{4}{S[table-column-width=1.25cm]}} \caption{Univariate Item Descriptives}\\ \toprule \multicolumn{1}{l}{\textbf{Item}} &amp; \multicolumn{1}{c}{\textbf{Mean}} &amp;    \multicolumn{1}{c}{\textbf{Variance}} &amp; \multicolumn{1}{c}{\textbf{Skewness}} &amp; \multicolumn{1}{c}{\textbf{Kurtosis}} \\ \midrule \endfirsthead \multicolumn{5}{c}% {\tablename\ \thetable\ -- \textit{Univariate Item Descriptives (Continued from previous page)}} \\ \toprule \textbf{Item} &amp; \textbf{Mean} &amp; \textbf{Variance} &amp; \textbf{Skewness} &amp; \textbf{Kurtosis} \\ \midrule \endhead \hline \multicolumn{5}{r}{\textit{Continued on next page}} \\ \endfoot \bottomrule \endlastfoot 2. EX +         &amp; 2.788   &amp;    1.060 &amp;        -0.120   &amp;   -0.368\\ 3. DS +         &amp; 4.080   &amp;    0.853 &amp;        -1.141   &amp;    1.379\\ 4. AM +         &amp; 3.684   &amp;    0.705 &amp;        -0.541   &amp;    0.744\\ 5. EX +         &amp; 3.653   &amp;    1.043 &amp;        -0.709   &amp;    0.149\\ 6. DS -         &amp; 2.240   &amp;    1.665 &amp;         0.725   &amp;   -0.603\\ 7. AM +         &amp; 4.292   &amp;    0.876 &amp;        -1.627   &amp;    2.705\\ 8. EX -         &amp; 2.419   &amp;    1.588 &amp;         0.449   &amp;   -0.897\\ 9. AM +         &amp; 3.255   &amp;    0.923 &amp;        -0.234   &amp;   -0.037\\ 10. DS -        &amp; 3.449   &amp;    1.408 &amp;        -0.453   &amp;   -0.599\\ 11. EX +        &amp; 3.678   &amp;    1.232 &amp;        -0.669   &amp;   -0.219\\ 12. AM -        &amp; 2.830   &amp;    1.162 &amp;         0.029   &amp;   -0.565\\ 13. EX -        &amp; 3.452   &amp;    1.205 &amp;        -0.410   &amp;   -0.336\\ 14. DS -        &amp; 2.442   &amp;    1.374 &amp;         0.310   &amp;   -0.893\\ 15. AM -        &amp; 2.114   &amp;    1.168 &amp;         0.729   &amp;   -0.176\\ 16. EX -        &amp; 3.070   &amp;    1.085 &amp;        -0.176   &amp;   -0.347\\ 17. AM +        &amp; 3.893   &amp;    1.116 &amp;        -0.954   &amp;    0.544\\ 18. EX +        &amp; 3.311   &amp;    0.964 &amp;        -0.238   &amp;   -0.066\\ 19. AM -        &amp; 2.674   &amp;    1.404 &amp;         0.245   &amp;   -0.780\\ \end{longtable} \end{document}
16410
Throughout my thesis, I have accent several mathematical symbols with &quot;hats&quot; and &quot;checks&quot;. My advisor noted that the standard \hat{}, \check{} accents were difficult to read due to their size, so I made my own in Tikz. However, now LaTeX takes several (around three) minutes to compile the entire document. Below is the code used to define these symbols. I do use the accents package. Is there a more efficient way to define custom accents for mathematical symbols? I imagine Tikz is running every time the compiler comes across my command which is what's slowing it down, but I'm not sure how to avoid this. I am using TexMaker with the latest MikTex distribution for Windows. % Some symbols   \newcommand{\myhat}{% \mathbin{\begin{tikzpicture}[line width = 0.15pt, smooth] \draw[smooth, fill] (0,0.1ex) -- ({0.5ex - 0.3pt},0.45ex) -- ({0.5ex + 0.3pt},0.45ex) -- (1ex, 0.1ex) -- (0.5ex ,0.4ex) -- (0,0.1ex); \draw[white](0,0ex) -- (0, 0.1); \end{tikzpicture}  }}  \newcommand \what [1]{ \accentset{\myhat}{#1} }  \newcommand{\mycheck}{% \mathbin{\begin{tikzpicture}[line width = 0.15pt, smooth] \draw[smooth, fill, rotate = 180] (0,0.1ex) -- ({0.5ex - 0.3pt},0.45ex) -- ({0.5ex + 0.3pt},0.45ex) -- (1ex, 0.1ex) -- (0.5ex ,0.4ex) -- (0,0.1ex); \draw[white](0,-0.5ex) -- (0, 0); \end{tikzpicture} }}  \newcommand \wcheck [1]{ \accentset{\mycheck}{#1} }
19022
I have something like this:  \usepackage{algorithm} \usepackage{algpseudocode}  ... \begin{document} \begin{algorithm}[H] \begin{algorithmic}[1] \Function {function}{a} \State a = a + 1 \EndFunction \end{algorithmic} \end{algorithm} \end{document}   I'm using [H] because I want to set the position of my code. But after doing that a space for caption appears and I don't want it and now there are to horizontal lines beafore my code. You can see what I mean in this picture:   How can I remove one of those lines?  Thanks!
33994
Khan Academy released , a library that does essentially the same job as MathJax does today -- only . Part of that is probably because (the hard?) part of the layout can be preprocessed on the server. This may also enable mathematics typesetting in apps more easily.  As of now, it does not offer all the symbols and functions MathJax has -- so we don't want to switch now -- but eventually we should consider moving over. MathJax is nice but it is just painfully slow on pages with many formulae, which sites like (math|cs|cstheory).SE have plenty.  Using KaTeX as primary engine with MathJax as fallback ; this solution would already speed up many a page.  Some site metas have picked this up: