title: How to speed up pdflatex for a very large document on MacOS X?

text: I wonder how I can speed up the `pdflatex` compilation of a large document (thesis) with >200 pages and many images (however all imported PDFs or imported pixel graphics, no `TikZ`or similar things yet!). My current LaTeX project has several source files, combined with `\include`. I read about `latexdaemon` which seems to be able to precompile the preamble to save time.   * Is there anything similar I can use on `MacOS X`?    * Are there ways to only process the things that have really changed? (I'm currently editing many chapters at the same time, so `\includeonly` seems not helpful.) I use `TexMakerX` as editor and `Skim`as viewer.   I've configured `latexmk` to automatically do several `pdflatex` runs (see Automatically start the necessary pdflatex runs if .tex has changed (MacOS X)?). `Skim` does autoupdate the PDF file, as soon as it has changed.


title: Change part of table column size

text: I would like to know if there is a way, that I can resize part of a column, while keeping the rest the same size. Such that I would get this: Column   **___ __**|   **___ __**|   **___ __**|   **___ __ ___ __ ___** |   **___ __ ___ __ ___** |   **___ __ ___ __ ___** | I have included my project below as tex and an image. The cells in want to change is Column 1, row 1 to Column 1, row 9.               \begin{sidewaystable}     \begin{center}     \caption*{\Huge {\bf Tjanseplan}}     \renewcommand{\arraystretch}{1.7}     \begin{tabular}{|l|l|l|l|l|l|}         \hline         Tidspunkt         & Type                    & Lørdag                                         & Søndag            & Mandag             & Tirsdag            \\ \hline         13:37             & Antikaos                 &  \cellcolor[gray]{0.8}                        & \cellcolor{Gyldesprederne_color}Gyldesprederne    & \cellcolor{Fuksvansene_color}Fuksvansene        & \cellcolor{Smørkærnerne_color}Smørkærnerne       \\ \hline         13:37             & Morgenmad            &  \cellcolor[gray]{0.8}                                & \cellcolor{Kvægdriverne_color}Kvægdriverne        & \cellcolor{Høtyvene_color}Høtyvene           & \cellcolor{Laderejserne_color}Laderejserne       \\ \hline         13:37             & Oprydning              &  \cellcolor[gray]{0.8}                      & \cellcolor{Laderejserne_color}Laderejserne      & \cellcolor{Smørkærnerne_color}Smørkærnerne       & \cellcolor{Gyldesprederne_color}Gyldesprederne     \\ \hline         13:37             & Frokost                  & \cellcolor{Smørkærnerne_color}Smørkærnerne    & \cellcolor{Fuksvansene_color}Fuksvansene       & \cellcolor{Gyldesprederne_color}Gyldesprederne     &  \cellcolor[gray]{0.8}    \\ \hline         13:37             & Oprydning              & \cellcolor{Kvægdriverne_color}Kvægdriverne       & \cellcolor{Høtyvene_color}Høtyvene          & \cellcolor{Fuksvansene_color}Fuksvansene        &  \cellcolor[gray]{0.8}    \\ \hline         13:37             & Aftensmad             & \cellcolor{Laderejserne_color}Laderejserne                                   & \cellcolor{Smørkærnerne_color}Smørkærnerne      & \cellcolor{Høtyvene_color}Høtyvene           &  \cellcolor[gray]{0.8}   \\ \hline         13:37             & Oprydning             & \cellcolor{Fuksvansene_color}Fuksvansene                                    & \cellcolor{Gyldesprederne_color}Gyldesprederne    & \cellcolor{Kvægdriverne_color}Kvægdriverne       &  \cellcolor[gray]{0.8}    \\ \hline         13:37             & Bolledej            & \cellcolor{Høtyvene_color}Høtyvene  & \cellcolor{Kvægdriverne_color}Kvægdriverne   & \cellcolor{Laderejserne_color}Laderejserne      &  \cellcolor[gray]{0.8} \\  \hline       \multicolumn{1}{ l }{} \\ \hline     \cellcolor{Smørkærnerne_color}Smørkærnerne          & \cellcolor{Kvægdriverne_color}Kvægdriverne            & \cellcolor{Laderejserne_color}Laderejserne       & \cellcolor{Fuksvansene_color}Fuksvansene       & \cellcolor{Høtyvene_color}Høtyvene           & \cellcolor{Gyldesprederne_color}Gyldesprederne     \\ \hline         Camilla Kiel         & Nadia Willumsen         & Alberte Thegler    & Hjalte Abelskov   & Kasper Hedegaard   & Simon Munck        \\ \hline         Adam Honeré       & Nick Pedersen           & Adrian Westh       & Morten Dreier     & Troels Thomsen     & Emilie Damkjær     \\ \hline         Martin Poulsen    & Morten Thaysen          & Sune Bartels   & Thomas Lorentzen       & Oliver Celest      & Troels Leskes      \\ \hline         Mikkel Kristensen & Simon Schleicher        & Jesper Christensen & Jeppe Hansen      & Stefan Duro        & Lasse Jensen       \\ \hline         Mikkel Knudsen    & Louise Hrouda-Rasmussen & Oliver Nielsen     & Mike Andersson    & Anna Vita Ross     & Signe Jensen       \\ \hline         Rasmus Andersen   & Sebastian Jensen        & Peter Meyer        & Peter Salomonsson & Sebastian Scheerer & Nikolaj Østergaard \\ \hline         ~                 & ~         & ~   & ~                 & ~                & Rasmus Haarslev   \\         \hline     \end{tabular}     \end{center}     \end{sidewaystable}      ![Image of project](http://i.stack.imgur.com/J9fZF.png)


title: How to put figures and tables together (in the same page) at the end? And leave some in the text?

text: I would like to put most of the figures and tables together (in the same page) at the end, while leave one of them in the text where it is referred. Now, I use               \usepackage[nolists,noheads,nomarkers]{endfloat}          \renewcommand{\efloatseparator}{\mbox{}}      The second is to block the separator after each figure. It works well except it will put figures and tables in separate pages. The requirement is a maximum of two pages of attached figures and tables. And I still have the problem of how to leave one of the figure in the text.


title: fontspec package not compatible with inline preview TeXStudio

text: I've installed MiKTeX 2.9 and TeXStudio 2.4. I found suggestions on the web to change the default compiler to XeLaTeX, to provide accentuated words (I am portuguese!), to handle any type of images (pdf, eps, jpg, etc) and also to use system fonts. This seemed very interesting, as I usually use pdfLaTeX. However, I am dealing with some problems that I would like to solve. First, I found that even with XeLaTeX we need to provide the `fontspec` package such as to have accentuated words (well, I could use pdfLaTeX and `fontenc` package with the same results). Is that right? If I build a file written in portuguese with XeLaTeX and without `fontspec` I get no accents. Second, when I use `fontspec` package, the Inline preview of TeXStudio does not work. Is there any known bug or incompatibility of `fontspec` with inline preview? So the problem is: Compiling with XeLaTeX and `fontspec` provides me with accents but no inline preview. Compiling with XeLaTeX without `fontspec` provides me inline preview and no accents! What am I missing?


title: Checklist with float images in the left side of the page

text: I want to create a document which is mainly a check list, but what I want is to show an image on the left side of the page, and the check list was shown in the right side of the page. Like the image below: ![the blue rectangle refer to the image, there are arrows in the images to associated with each check list items](http://i.stack.imgur.com/gSUaX.png) My question is, what is the way to do this in LaTeX, I have read some discussions about `multicols` package, but it does not support float images. **Question** : Now, I modify your code a little to create a landscape page:               \documentclass{article}     \usepackage[landscape]{geometry}     \usepackage{graphicx}     \usepackage{amssymb}     \usepackage{array}     \newcounter{rowno}     \setcounter{rowno}{0}     \begin{document}     \noindent     {\begin{minipage}[t]{.5\textwidth} %minipage's width     \raisebox{-.94\textheight}{%     \includegraphics[width=.95\linewidth,height=\textheight]{example-image}     }     \end{minipage}%     \begin{tabular}{@{\hspace{1em}\stepcounter{rowno}\therowno.\hspace{.5em}}p{.45\textwidth}c@{}}        \multicolumn{2}{c}{\large\bfseries Check list}\\[.5em]        This is first item to be checked & $\square$\\        This is second item to be checked and this sentence is going to the second line & $\square$\\        This is third item to be checked and this sentence is going to the second line & $\square$\\        This is fourth item to be checked and this sentence is going to the second line & $\square$\\        This is fifth item to be checked and this sentence is going to the second line & $\square$\\        This is sixth item to be checked and this sentence is going to the second line & $\square$     \end{tabular}     \end{document}      But I see the generated pdf have two pages, the first page is empty, I'm not sure why? **Another question 1** : What does the line `@{\hspace{1em}\stepcounter{rowno}\therowno.\hspace{.5em}}p{.45\textwidth}c@{}` is used for, I don't know, I guess this is used to align the table with the `minipage`, but I don't know why. **Another question 2** : Why do you use a `\raisebox{-.94\textheight}`, if I remove this, I see the image can still show there, but the check list items will go to the right bottom side of the image. **EDIT** : Two images added (before and after of removing the line containing the `raisebox` command) ![The image before remove of the raisebox line](http://i.stack.imgur.com/9vpBD.png) ![The image after I remove the raisebox line](http://i.stack.imgur.com/rPgM9.png)


title: WMF format in Latex

text: How to add large picture which has a `WMF` format in a tex file without breaking it? When I convert the image it look fuzzy to me. I want to add the pic .wmf in Latex and it doesn't factor that how much space it is taking. I can email you the image if you need cause I can not post it here.


title: LaTeX color setting for math mode

text: I'm wondering if it's possible to do something like this in LaTeX: For all numbers (0, 1, ..., 9) in math mode, color it red. For alphabets (a, b, ..., z, A, B, ..., Z) in math mode, color it green. For everything else in math mode, color it blue. I want to make my document more colorful, but doing manual coloring takes too much time!


title: Inserting a clickable URL into moderncv not working anymore

text: I tried inserting a clickable URL into ModernCV but somehow the output doesn't feature a clickable URL. This has worked in the past(on Ubuntu 12.04; with few changes such as including hyperref. Not required now since moderncv includes it) but no longer works in Ubuntu 13.10. Here's an MWE demonstrating the issue. On compiling this, I get "Google" highlighted in NavyBlue but it is not clickable. Could someone point out what could be possibly wrong!               \documentclass[11pt,a4paper,usenames,dvipsnames,svgnames,table]{moderncv}          \moderncvtheme[blue]{classic}     \usepackage[scale=0.8]{geometry}     \usepackage[utf8]{inputenc}     \usepackage{xcolor}          \firstname{First name}     \familyname{Last name}     \title{Curriculum Vitae}     \address{Address line 1}{Address line 2}     \mobile{Phone}     \email{Email}          \AtBeginDocument{\hypersetup{colorlinks, urlcolor=NavyBlue}}          \begin{document}       \section{Education}       \cventry{Year}{Degree}{University}{Location}{GPA. \href{http://google.com}{Google}}{}     \end{document}      I think I've explained the issue clearly but if there is something I could add, kindly do let me know. I'm running the following version of pdflatex on Ubuntu 13.10:               $ pdflatex -v     pdfTeX 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)     kpathsea version 6.1.1     Copyright 2013 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).     There is NO warranty.  Redistribution of this software is     covered by the terms of both the pdfTeX copyright and     the Lesser GNU General Public License.     For more information about these matters, see the file     named COPYING and the pdfTeX source.     Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).     Compiled with libpng 1.2.49; using libpng 1.2.49     Compiled with zlib 1.2.8; using zlib 1.2.8     Compiled with poppler version 0.24.1      Edit: Corrected arguments of `\cventry` and `\address`. Edit 2: Turns out what @IanThompson suspected was true. It is an issue with the PDF viewer I was using - Okular; the URL works fine with xpdf and Evince. I'm not closing this question though. I know it's not strictly a TeX issue but varying outputs on different editors doesn't seem good(at least to me) - a potential employer finds an unclickable URL might get annoyed, causing unnecessary issues(there can be more possible cases too). If someone can propose a solution to this, it would be great. And no @IanThompson's answer of adding 'www.' before 'google.com' didn't work either.


title: What Linux operating system contains patgen for hyphenation?

text: This question follows previous one. In TexLive, patgen command prompts error of "No such file or directory". I found at About.com that Linux contains patgen. I have Linux Red Hat 9.0 in my system. Can you let me know if it has this patgen command, in what directory?


title: LaTeX Numbering in Counters Appears to have Changed

text: I work on a project called OpenIntro (http://openintro.org), and we have created custom numbering for tables and figures within an open-source textbook so that tables and figures use a common counter. Recently, it seems the way LaTeX handles counters has changed. I now only see even numbers (1.2, 1.4, 1.6) where before there was regular numbering (1.1, 1.2, 1.3). Any idea on if there have been updates to the way counters are handled in LaTeX? If so, was a bug introduced or a bug fixed? I'm trying to assess whether I should be waiting for a fix or implement a fix myself. I don't want to do the latter if whatever changed is soon reverted. In case anyone wants to take a closer look at the code used for the counters, the source files are at http://www.openintro.org/stat/textbook.php (click the second main link, then scroll down to see the LaTeX source files link) The counter code is in "extraTeX > style > styleV5-print.tex" around line 155. Thanks for any tips or info you can offer! David


title: Where to find the source code to the ConTeXt manuals?

text: Quite a number of helpful manuals can be found at the Web page of PRAGMA ADE. Some have some very interesting designs. I wonder, is there a place to download the source code for some or all of these manuals?


title: Recommended workflow for fixing several nasty frames in beamer?

text: I have a pretty long presentation: a course comprising a couple of hundreds frames. Occasionally, I go over the presentation, notice a few corrections in distinct frames. Fixing these requires a number of iterations to find the most pleasing placement of objects, texts, and figures. Needless to say, running LaTeX on the entire presentation is time consuming. Instead, I mark the slides with `label=current` and use `includeonlyframes{current}` which renders only the `current` slides. However, I get the annoying                LaTeX Warning: There were multiply-defined labels.      Is there a more civilized way of managing the workflow. It seems too cumbersome to mark each slide with a different label, and then enumerate the labels in the `includeonlyframes` command.


title: Resuming in enumerate with roman numerals

text: I want to suspend and resume an enumerated list, with Roman numerals. I am using the enumerate and mdwlist packages and have the following:               \begin{enumerate}[I]     \item Item     \item Item     \suspend{enumerate}     Text in between...     \resume{enumerate}     \item Item     \item Item     \end{enumerate}      But the way it comes out is that the first two items (before suspending) are numbered I and II (as desired), and the second two items (after resuming) are numbered 3 and 4. How do I get those to be numbered III and IV?


title: Too many white space in bottom of the pages

text: I used this code for my thesis               \documentclass [12pt,oneside,final]{book}     \usepackage[left=35mm,top=26mm,right=26mm,bottom=15mm]{geometry}     \raggedbottom      It shows acceptable white space in bottom of the page at the PDF viewer but when I print it out it looks too large! any idea


title: Refer to labels of merged pdfs?

text: Do I need to use an extra program (pax) in order to bookmark labels of merged pdfs? For my application, I use KOMA-Script for the letter and `moderncv` for the CV. Therefore, I have to use two different document classes, so I have to merge my `pdf`s. The table of content or the bookmarks of my CV sections are lost. It is possible to refer to complete pages while merging PDFs, but am I somehow manually able to refer to labeled sections without the hassle of an external program? **Update:** Added a picture that shows how bookmarks refer to the document structure which is finer than pages. I don't need to reuse these bookmarks, adding them manually in the `merger.tex` would be great, too. ![modernCV example](http://i.stack.imgur.com/6pcYM.jpg)


title: Various \textcolor within lstlisting?

text: How can you set various words in your lstlisting to various text colors? For instance, I want the word "fail" to appear in red and the word "pass" in green. I have the feeling there should be some easy escape possibility!? ## What did not work I tried using the parameter               escapeinside={(*@}{@*)}      and then within the lstlisting               (*@\color{red}@*) fail (*@\color{black}@*)      But this has no effect. Therefore, I've tried               $\textcolor{red}{\lstinline!fail!}$      but listings does not like nested lstinline within lstlistings. ## Complex solution a not quite suitable solution is described in \textcolor within lstlisting?: it is intended for one color only, so I would have to add something like               moredelim=**[is][\color{red}]{@}{@},      for every color I use :(


title: DraftMark error - Package not found

text: I compiled my tex file which showed me that the draftmark package is not found. Hence I gave the command, `tlmgr install draftmark` but I get the following error,               tlmgr: package repository http://ctan.imsc.res.in/systems/texlive/tlnet     package draftmark not present in package repository.      What do I do? I updated my tlmgr with the self option. I am using Ubuntu 13.10 64-bit


title: TeXworks actually shows stylesheet on startup when using -stylesheet argument in filepath

text: Recently I came across this, which allows for customization of the TeXworks visual appearance of code and the likes. I made that `.css` file:               QTextEdit {       background-color: black;         color: white;            /* sets the main text color */     }      ...but now TeXworks actually opens this file, instead of booting with an empty document. My full filepath, including argument, reads:               ~\texlive\2013\bin\win32\texworks.exe -stylesheet "somepath/style.css"      Using `-stylesheet="somepath/style.css"` doesn't load the `style.css` file, but _does_ give an error on startup. Both with and without the equals to sign, the style is applied as normally, though: ![http://i.imgur.com/TPLY76a.jpg?1](http://i.stack.imgur.com/C3XT2.jpg) I'm running TeXworks 0.4.5 r.1280 and Windows 7 Home Premium SP1 (possibly localized issue ?)


title: Create a footnote in node in a tikzpicture

text: I would like to add a footnote to a node in a TikZ picture, but every solution I could imagine fails. I tried using a minipage, too.               \documentclass[a4paper,10pt]{scrartcl}     \usepackage{tikz}          \begin{document}     \begin{tikzpicture}     \foreach \x/\y/\number/\year in {       0.5/0.46/ 4.624/2001,       1.5/0.89/ 8.965/2002\footnotemark,       2.5/1.18/11.892/2003     }     {       \draw (\x cm, 0 cm) rectangle (0.5 cm + \x cm, \y cm) node at (0.25 cm + \x cm, \y cm + 0.25 cm) {\tiny\number};       \node[rotate=45, left] at (0.6 cm +\x cm,-0.1cm) {\year};     };     \end{tikzpicture}     \footnotetext{foo}     \end{document}      The output shown is               ! Missing number, treated as zero.     <to be read again>                    }     l.18   }         ;      The footnote text is displayed correctly, but the footnote mark is not. I tried using a minipage as following. I replaced               \node[rotate=45, left] at (0.6 cm +\x cm,-0.1cm) {\year};      with               \node[rotate=45, left] at (0.6 cm +\x cm,-0.1cm) {\begin{minipage}{2em}\year\end{minipage}};      Follow-up question: How to create multiple footnotes with the hyperref package?               \documentclass[a4paper,10pt]{scrartcl}     \usepackage{tikz}          \usepackage[     pdfpagelabels,     pdfstartview=FitH,     plainpages=false,     hypertexnames=false     ]{hyperref}          \begin{document}          \begin{tikzpicture}            \foreach \x/\y/\Number/\Year in {           0.5/0.46/ 4.624/2001,           1.5/0.89/ 8.965/2002\footnotemark,           2.5/1.18/11.892/2003\footnotemark       }       {         \draw (\x cm, 0 cm) rectangle (0.5 cm + \x cm, \y cm) node at (0.25 cm + \x cm, \y cm + 0.25 cm) {\tiny\Number};         \node[rotate=45, left] at (0.6 cm +\x cm,-0.1cm) {\Year};                 };          \end{tikzpicture}          \footnotetext{foo1}     \footnotetext{foo2}          \end{document}


title: How to scale fonts including sections and subsections?

text: I am trying to scale the fonts in my document with the `scalefnt` package. However it only affects the body text and not the section or subsection headings, as the following example shows:               \documentclass[a4paper,12pt]{article}          \usepackage[utf8]{inputenc}     \usepackage{fontenc}          \usepackage{scalefnt}          \begin{document}          \begingroup     \scalefont{2}     \subsection*{Test}          Test     \endgroup               \subsection*{Test}          Test          \end{document}      Output: ![Output](http://i.stack.imgur.com/xN2KA.png) Is there any way to make this work or another way to scale all fonts including section and subsection headings by the same factor?


title: How do I make my desired font be the default font in the memoir class?

text: I was confused by reading something regarding this topic in the `memoir` documentation. Can't I just load the package directly so that it can be the default font in my document?


title: how to eliminate the horizontal spacing of the frame in the framed package?

text: I'm using the framed package and I found it difficult to adjust the width of a frame to adapt to the current environment, e.g. if I use a `shaded` environment within the `enumerate` environment, I will get a frame box as wide as the current page (actually slightly wider) -- it will not indent accordingly; then I found a solution to make the frame of the same width as the current environment, but a new problem arised: there seems to be extra horizontal spacing inside the frame. A MWE is below:               \documentclass{article}     \usepackage{framed,color}     \definecolor{shadecolor}{rgb}{.9, .9, .9}     \newenvironment{myframe}{%     \def\FrameCommand{\fboxsep=\FrameSep \colorbox{shadecolor}}%     \MakeFramed {\hsize\linewidth\advance\hsize-\width \FrameRestore}}%     {\endMakeFramed}          \begin{document}     test a frame within an enumerate environment       \begin{enumerate}       \item abc         \begin{myframe}         def         \end{myframe}       \end{enumerate}     \end{document}      Can anybody tell me how to eliminate the extra left padding so that the content of the frame can align to the list item? Thanks a lot! A screenshot is here: ![http://i.stack.imgur.com/VR1SF.png](http://i.stack.imgur.com/BK4iV.png)


title: flowfram: more dynamic page range

text: My purpose is a document template which allows me to set up various text frames on each page including columns/graphics/... . To realize this, I chose `flowfram` because it seems to be the only package of this type out there. So far, the package does its job but I've some headache about how the frames are defined. Each frame needs a specified page range (e.g. 1,3-6,>8) set in the preamble. Now when writing a long document with masses of frames declared, it maybe doesn't make any problems if you write your content straight down. But, when you like to edit and add some content somewhere in the middle of the document, the whole design breaks and ends in a mess. The only way - as I understand - is to redefine all the frames behind/afterwards of the edit. Is there any trick to handle this more comfortably? I tried to make use of a counter defined by my own, but the counting sequence breaks in the preamble (because of `flowfram`). For example: I would like to have a 3-column-design (`\Ncolumn`...) over 4 pages or so, and on the second page of them I need a completely different layout to include e.g. a graphic. In this case you would - in my understanding - declare `\Ncolumn[1]{3}` followed by a more complex definition for page 2 and then end with something like `\Ncolumn[>3]`. As far as I know, there is no possibility to "pause" (save+resume) a running design. Now let's assume that the document under discussion has about 106 pages with 2/3 unique layouts, and you need to add about 10 pages somewhere at the beginning. You add your text, and then you need to redefine all the defined pages. The simplest way would be to just add an increment of about 10. Now be to honest, this isn't an adequate solution at all if you have more than 200 frames. Does anybody have a solution that allows to set the page ranges in a more dynamic/relative way? Or to overwrite layouts pagewise? Or, what about overlaying frames resulting in wrapped text (graphics)? It would help me so much.


title: Convert Latex to odt using tex4ht

text: Based on advice from this question I'm trying to use tex4ht to convert a latex document into something readable by MS Word. I was planning to use tex4ht to convert `.tex` to `odt` format. I'm running into problems though. I'm using a mac, and have TeXShop installed. I ran the line:               mk4ht oolatex myfile.tex       but I then got the message:               ! LaTeX Error: File `preamble.tex' not found.      The file `preamble.tex` does exist in my main document; I linked the file by using the line `\input{preamble}` in `myfile.tex`. As `myfile.tex` is very large I want to use a lot of `input{}` commands. Is there a different command (or approach) that I can take to convert this file? Just to clarify, I also ran the command in the form `htlatex myfile.tex` which resulted in the same error message.


title: Normal subgroups

text: To typeset that H is a normal subgroup of G, I would use `H\unlhd G`. However, the result doesn't satisfy myself, since the G seems too close to the triangle: ![enter image description here](http://i.stack.imgur.com/e7USU.png) Adding a space `\` makes "too much space". Is there a neat way to typeset such a thing ?


title: How to define a new math operator with \mathclap in its arguments?

text: I would like to define a math operator with `\mathop` and I would like its arguments to be automatically put in a zero width box with `\mathclap`. Defining an operator, e.g. `\sum`, with `\newcommand`               \newcommand{\Sum}[2]{\sum_{\mathclap{#1}}^{\mathclap{#2}}}      would do, but it would force me to provide every time two arguments. If I define the new command with an optional argument, that wouldn't solve the matter, since the mandatory argument is still to be provided (and I may need only the optional in some occurrences). Besides `\mathop` doesn't require a specific order of the arguments, while `\newcommand` does. Any ideas?


title: Draw lines inside tikz plot (exported from matlab), independent of coordinate system

text: I am exporting plots from matlab with the `matlab2tikz` package. While this works just fine, I now want to insert some lines and text to describe the plot. I have multiple plots which are to be labelled but which have different coordinate systems. That is why the labels and lines are not in the same place if they refer to the coordinate system of the plot. Here is where it works well. ![output of the correctly appearing plot](http://i.stack.imgur.com/AgiQ4.png) Here is where it looks incorrect. ![Wrong](http://i.stack.imgur.com/CQFLF.png) Both are included in a wrapping tex document, which includes both of them like this:               \begin{figure}[H]     \centering     \newlength\figureheight      \newlength\figurewidth      \setlength\figureheight{0.5\textheight}      \setlength\figurewidth{\textwidth}           \input{graphen/dotierung.tikz}     \caption{Energieverläufe $V$}     \end{figure}      I already played around a little with the coordinates but I have to change the y-Axis coordinate totally in order to have a pleasing result. That seems to be caused by the completely different scaling of the two plots. Now, is there a way to use the same coordinates on both plots for the lines and the text? It is important that the labels keep their relative positions when I scale the plots.


title: \thanks in IEEEtran adds an extra page

text: When I use "\thanks" in IEEEtran, an extra page including a "1" at the top left corner appears before the first page. Here is a MWE:               \documentclass[english]{IEEEtran}     \usepackage[T1]{fontenc}     \usepackage[latin9]{inputenc}     \usepackage{babel}     \begin{document}     \title{Title Title Title Title Title}     \author{Author Author Author Author Author}     \thanks{This work was supported in part by NSF.}     \maketitle     \end{document}


title: Listings Highlight Java Annotations

text: I am typesetting something that has a lot of Java code listings. Because the Java code has a lot of annotations, and that they are important to the reader, I'd like to have them highlighted, like other keywords such as class, public, etc. I want the output to be in black and white. I tried using minted, but the bw output does not highlight the annotations. How can I arm-twist listings to highlight the annotations? P.S. Here is the lstset that I am using:               \lstset{       basicstyle=\footnotesize\tt,        % the size of the fonts that are used for the code       breakatwhitespace=false,         % sets if automatic breaks should only happen at whitespace       breaklines=true,                 % sets automatic line breaking       captionpos=b,                    % sets the caption-position to bottom       extendedchars=true,              % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8       frame=single,                    % adds a frame around the code       language=Java,                 % the language of the code       keywordstyle=\bf,       showspaces=false,                % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'       showstringspaces=false,          % underline spaces within strings only       showtabs=false,                  % show tabs within strings adding particular underscores       tabsize=2                       % sets default tabsize to 2 spaces     }


title: Automatic numbering -- place code 1. anywhere in 2. the main 3. body

text: Is it possible to insert a code anywhere in the main body that will generate an automatic number with a period: `1.` `2.` `3.` ? Instead of automatic paragraph numbering (with lots of restrictions), it would be nice to have a code for automatic numbering without restrictions: `\autonum` anywhere. I'm looking to avoid complications with other codes, and I do not want an `outline` feature per se where every new line or paragraph gets assigned a number; and I would like the ability to reset the numbering. The examples I've tried based upon searches for automatic paragraph numbering do not offer the flexibility I'd prefer.               \documentclass{article}          \usepackage{tabto}     \TabPositions{0.5in,1.0in,1.5in,2.0in,2.5in,3.0in}          \begin{document}          \tab    1.  \tab     On May 20, 2013, I read the case \textit{Smith v. Smith}.                          *     The buyer shall beware.     \tab    2.  \tab     On May 21, 2013, I witnessed an incident.          \newpage          1.     \tab     Plaintiff shall deposit the sum of . . .     2.     \tab     Both parties shall prepare declarations . . .          \newpage          \tab     \tab     \tab     1.     \tab     Every good boy deserves fudge.     \tab     \tab     \tab     2.     \tab     It is almost Wednesday . . .          \end{document}


title: Ignoring specific ampersand formatting on a specific line of an align block

text: I want to typeset a number of equations with some alignment constraints, but I want to partially ignore them on certain lines. An example formatted text might look like the following when it's formatted               really really really long equation = a           a = b                      b = c           c = d                      d = e      where the equals signs in each column are aligned, but the top line ignores the first column of alignment. This is essentially the same question as Ignoring alignment for certain lines in an alignat environment, but that question wasn't answered satisfactorily. The two naive ways both produce undesirable results.               \documentclass{article}     \usepackage{amsmath}          \begin{document}          \begin{align*}       && \text{really really really long equation} &= a \\       a &= b & b &= c     \end{align*}               or     \begin{align*}       \text{really really really long equation} &= a \\       a &= b & b &= c     \end{align*}          \end{document}


title: LaTeX and Table formatting

text: \documentclass{article}     \usepackage[english]{babel}          \begin{document}          Without specifying width for last column:     \begin{center}         \begin{tabular}{| l | l | l | l |}         \hline         Day & Min Temp & Max Temp & Summary \\ \hline         Monday & 11C & 22C & A clear day with lots of sunshine. However, the strong breeze will bring down the temperatures. \\ \hline         Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells         across most of Scotland and Northern Ireland,         but rain reaching the far northwest. \\ \hline         Wednesday & 10C & 21C & Rain will still linger for the morning.         Conditions will improve by early afternoon and continue         throughout the evening. \\         \hline         \end{tabular}     \end{center}     \end{document}      **I want to bold the line of the first row-column and last row-column** How to do this?


title: How to put captions below tables residing in multiple columns

text: I made the following document, consisting of 2 tables in 2 columns: ![enter image description here](http://i.stack.imgur.com/kAd6h.png) Code:               \documentclass{article}     \usepackage[a5paper]{geometry}     \geometry{verbose,tmargin=1cm,bmargin=1.5cm,lmargin=0.7cm,rmargin=0.7cm}     \setlength{\parindent}{0cm}     \usepackage{multicol}     \begin{document}     \begin{centering}     \begin{multicols}{2}     \begin{tabular}{ | c | c|c|c| }       \hline       i & 1 & 2 & 3\\       \hline       $V$ & 10 & 8 & 12\\       \hline     \end{tabular}          \begin{table}[h!]     \begin{tabular}{ |c|c|c|c| }       \hline       i & 1 & 2 & 3\\       \hline       $N_2$ & 1 & 0 & 1\\       \hline     \end{tabular}     \end{table}     \end{multicols}     \par     \end{centering}     \end{document}      How to put \captions beneath each of them like this: ![enter image description here](http://i.stack.imgur.com/LjLH5.png) I tried to wrap \tabular into \table environment, but then the table disappeared.


title: How to edit header of one page of book class?

text: I use the `book` document class and make the headers with `fancyhdr`:               \documentclass[12pt, a4paper, reqno, oneside]{book}          \usepackage{amsmath,amsxtra,amssymb,latexsym, amscd,amsthm}     \usepackage{fancyhdr}          \lhead{gggggggggggggggggggg }          \rhead{\parbox{0.58\linewidth}{\begin{center}\small{\leftmark}\end{center}}}          \rfoot{\thepage}          \renewcommand{\headrulewidth}{0.2pt}          \renewcommand{\footrulewidth}{0.2pt}     \makeatletter          \let\ps@plain\ps@fancy          \makeatother          \begin{document}          \end{document}      Now I want to change right header on one page, can you help me ?? I tried to use : `\thispagestyle{empty}` to delete the header on one page.


title: How can I automatically add index entries every time I reference a glossary entry?

text: I'm making heavy use of the `glossaries` package, and I have created a custom glossary with a type I call `concepts`. I am trying to come up with a single command that both links to the `concepts` glossary and to my index. I have seen a few quick 'n' dirty ways to do this for `\ac` (and I could use the same approach for `\gls`), but I'd like to see a more robust approach -- one that affects the whole family of `\gls` commands (e.g. `\glspl`, `\Gls`, etc.). Is it possible to do this without renewing each of those commands individually, to avoid repetition of code, or would that be required for this task? I also want the whole set of glossary-references to link to the `\name` key of the glossary entry to avoid redundant glossary entries. The following should link to the same glossary entry (`star`), should all show up as unique hits for a single entry in the index, but should display different text according to which glossary reference command is used. That is, I want them to fall under the same index entry rather than one index entry called "star", another called "Stars", and yet another called "stellar". (Does that make sense?)               \mygls{star} should look like ``star'' and link to the glossary entry {star} and index entry {Star}.      \myGls{star} should look like ``Star''.      \myglspl{star} should look like ``stars''.      \myGlspl{star} should look like ``Stars''.      \myglslink{star}{stellar} should look like ``stellar''.      I recognize that this question is similar in spirit to other questions asked, but with a few differences that together make my question unique:   * I need this to be done for all glossary references in the text of my document -- not just a single index entry linking to the glossary entry itself. (Compare to this question.)   * I want more than just `\gls` overloaded: it should overload the other glossary reference commands as well. (Compare to the solution to this question.)   * I want to do this for glossary entries of a specific glossary -- not just the default acronym glossary. (Compare to this question.) Thanks in advance!


title: Auto goto active line TeXstudio

text: I have used TeXstudio for some time. Since my computer crashed the other day, I had to reinstall it. After I have reinstalled TeXstudio it have stopped automatically going to the active line. Previously it would automatic go to the active line in the `pdf`, that the cursor was on in the `tex` file. A function I really much enjoyed, but it have stopped doing this now. Anyone aware of how to reactivate this function?


title: How many pixels, inches or centi meters is a linewidth in a two columned article?

text: I'm writing an article. The article consists of two columns and is created using:               \documentclass[10pt, aps, prb, twocolumn]{revtex4-1}      How long is a `1.\linewidth` in pixels, inches or centi meters?


title: Horizontal alignment across nested aligned

text: Is there a way to left align the first 2 rows with the last one? ![enter image description here](http://i.stack.imgur.com/xwkKc.png)               \documentclass{article}     \usepackage{amsmath}     \begin{equation*}     \left\{{\begin{aligned}     &\left.{\begin{aligned}     &A+B=X\\     &B+C=Y\end{aligned}}\right\}2A+B+C=X+Z\\     &C+A=Z     \end{aligned}}\right.     \end{equation*}     \end{document}


title: pst-optic example creates unrecoverable error for Ghostscript

text: I'm trying to reproduce an example (figure 8) from the pst-optic documentation and it creates an unrecoverable error for Ghostscript (version 9.02). This is on a Mac using TeXShop. I have updated pst-optic to the latest version form TeXlive. Here is the example:               \documentclass[11pt]{article}          \usepackage{pst-optic}     \usepackage{auto-pst-pdf}          \begin{document}          \begin{pspicture*}(-7.5,-2.75)(7.5,3)      \rput(0,0){\lens[lensScale=0.6,XO=-4,nameF=F_1,nameA=A_1,nameB=B_1,     nameFi=F’_1,nameAi={ },nameBi={},nameO=O_1,focus=1,OA=-2,lensGlass=true, lensWidth =0.5]}     \pspolygon[style=rayuresJaunes,linestyle=none](B)(I)(B’)(I’)(B)      \Transform      \rput(0,0){\lens[lensScale=1.2,XO=2,focus=2,nameA=A’_1,spotA=90,nameB=B’_1,spotB=270,     nameO=O_2,nameAi=A’_2,spotAi=270,nameBi=B’_2,spotBi=90,nameF=F_2,nameFi=F’_2,     lensTwo=true,lensGlass=true,lensWidth=0.5]}      \pspolygon[style=rayuresJaunes,linestyle=none](B)(I)(B’)(I’)(B)      \end{pspicture*}          \end{document}        Any help or pointers would be appreciated. (Note that I would have liked to add pst-optic as a tag to this question but do not have reputation to do so.)


title: compile both one-sided and two-sided version of my document by a single typestting

text: I use Book class to compile a journal and need to prepare both one-sided and two-sided versions of the journal which have different settings (margins, ...). Each time I make a change in my TeX file, I have to apply the change to both versions. Is there any way to typeset both versions by a single file and a single click?


title: adding a mathematical symbol in front of an item bullet

text: How can I have, say an `\implies` symbol _before_ each number in an enumerate environment?


title: How to change the mathematical symbol class of a unicode math symbol?

text: In `unicode-math-table.tex` the math class of many symbols is defined by lines like: `\UnicodeMathSymbol{"026AC}{\mdsmwhtcircle}{\mathord}{medium small white circle}%` Now if I want to use this particular circle as binary operator for function composition I have to change its math class to `\mathbin`. What I would like to do in the preamble is something like:               \usepackage{unicode-math}%     \UnicodeMathSymbol{"026AC}{\mdsmwhtcircle}{\mathbin}{medium small white circle}%`      Thereby overwriting `unicode-math’s` defaults. However the marco `\UnicodeMathSymbol` seems only to be available internally, when `unicode- math` processes `unicode-math-table.tex`. Of course I can copy `unicode-math-table.tex` to a local texmf-tree, modify it and achieve the desired result. But I would prefer to keep this change local to the document and make the change in the preamble. How can I overwrite `unicode-math’s` defaults with regard to the symbols math class?


title: Is it possible to change .ist (index style) file parameters mid-document?

text: Apart from the general document layout, the layout and formatting of indexes depend on two things:   * The parameters of `.ist` (index style) files that are used by `makeindex` when transforming raw index data into `.ind` files (which contain a `theindex` environment). These parameters control, e.g., the presence of letter headings to each index group.   * The definition of the `theindex` environment which is part of document classes and may be changed by packages like `imakeidx` and `idxlayout`. This definition controls, e.g., the number of index columns. It is possible (although often not sensible from a typographic point of view) to change the definition of the `theindex` environment mid-document (e.g., _"typeset[ting] a general index in two columns and then switch[ing] to three columns for an index of names"_ , `idxlayout` manual, p. 4). But is it possible to change `.ist` (index style) file parameters mid-document (e.g., adding letter headings for groups in some, but not in all indexes)? EDIT: To clarify: My aim is not to switch `.ist` parameters within a single `theindex` environment, but to use different parameters (or achieve a different formatting) for several indexes within the same document. EDIT 2: I take Martin Schröder's answer as a hint that it is possible to run `makeindex` "by hand" several times and to choose different `.ist` files each time. On the other hand, Leo Liu states in a comment that one _"can add TeX boolean switches in the`.ist` format and modify `\index` to make it work"_, i.e., control the formatting through LaTeX macros. I'd be interested in a concrete example of a boolean switch within an `.ist` file.


title: dblfnote.sty with musuos.cls causes unbalanced footnotes

text: I’m the author of `musuos.cls` and while writing a paper with it I noticed that the `dblfnote`-package leads to unbalanced footnote columns ![enter image description here](http://i.stack.imgur.com/lrsZg.jpg) You can see that the left colum has one line less than the right one but I’d expect that it is the other way around. This is the MWE               \documentclass[         twocolfnotes,     ]{musuos}          %% class option or this code (which is activated by the options)     %% cause the problem     %\usepackage{dblfnote}     %\setlength{\DFNcolumnsep}{2em}     %\setkomafont{footnote}{\scriptsize}          \usepackage[T1]{fontenc}     \usepackage[latin1]{inputenc}          \usepackage[ngerman]{babel}     \usepackage{blindtext}     \begin{document}     \Blindtext[2]     \footnote{Vgl. Frank Hentschel: Das Ewig-Weibliche --         Listz, Mahler und das bürgerliche Frauenbild. In:         Archiv für Musikwissenschaft 51.4 (1994), S. 274--293, S.286.}     \footnote{Vergleiche S. 4 und Notenbeispiel 4.}     \blindtext[3]     \end{document}      I can’t find out why this problem occours …


title: Removing page number from ToC while maintaining header/footer information

text: I am editing a document that was created by someone else. The original document has a custom header/footer and the page numbering was commented out. All I wanted to do was to turn the page numbering on. I figured out how to do that, however, in doing so, the ToC (which also uses the header/footer) now shows page numbering as well. The document has a cover page, a blank page, a title page, then the ToC. Because I don't care to show the header/footer on the first 3 pages, I can use the `\thispagestyle{empty}` command and thus not show any page numbers. However, I do want to maintain the header footer information (minus the page numbering) in the ToC. FYI, the ToC itself is 6 pages long. The page numbering on the first page of the ToC starts with page 4. How can I suppress the page numbering on all 6 ToC pages while still maintaining the rest of the header/footer information?


title: fancyvrb: multiple actives

text: this works great---well, I stole it right out of the docs:               {       \catcode`!=\active       \begin{Verbatim}[defineactive=\def!{\color{red}\bf}]         black     !   red         black       \end{Verbatim}     }      now I would like to have multiple active characters, each designating a particular style. I could bore everyone with my code that tries to generalize this to two or three characters (define '-' as active, then add another defineactive with a comma), but they were all wrong. is this easy? a related question (not needed) is whether one can easy switch forth and back on the same line. advice appreciated.


title: \citeauthor without natbib

text: I need to use a style file that does not allow use of `natbib`, but I still want to use something similar to the `\citeauthor` or `\citet` command from `natbib`. This is identical to this question, but that answer is unacceptable. I've also tried using `biblatex`, but the results were not close enough to the `abbrv` style that I need to use for BibTeX. Does anyone know a way around this? Edit: the bibliography style isn't the issue. The stylefile doesn't allow using `natbib`. Edit: Another restriction is I have to eventually make a self contained file. The recommendation is copy the `.bbl` in to where the bibliography section was, but I was unable to get a procedure like that to work with `biblatex`.


title: How to make table extend onto second column

text: I have a two column document and a long table. I would like the table to start in one column and then extend into the next column. I know about the `table*` environment; I don't want a table that is the width of both columns of the text. I want a table that is the width of one column of text, but longer than the column of text so it has to extend on the the next column. Is this even possible in LaTeX? I know I can do this in Word (ick!).


title: deletekeywords in Listings package sometimes doesn't work

text: Using the listings package, I can use `deletekeywords` to remove keywords, and so the keyword is not rendered in bold. For example, the `for` from the following is not in bold font:               \lstset{language=[]C++}     \begin{lstlisting}[deletekeywords={for}]     for (int i = 0; i < 8; i++) {}     \end{lstlisting}      This is useful as I like to use the same font for small code snippets within the main body of my text, but don't always want it to appear with keywords in bold. I came up with two commands for convenience:               \newcommand{\code}[1]{\lstinline[deletekeywords=#1]{#1}}     \newcommand{\codeb}[1]{\lstinline[morekeywords=#1]{#1}}      However, with Fortran it doesn't work. The `do` in the following is still in bold.               \lstset{language=[]Fortran}     \begin{lstlisting}[deletekeywords={do}]     do i = 1,8     end do     \end{lstlisting}      Is there a way to do this? To locally override the keyword/language highlighting settings more generally?


title: What is the best way to learn TeX?

text: As opposed to LaTeX, which is addressed in another question. Most of the references I've seen get too complex too quickly. I'm looking for something that gives me a top-down view of the language - what the parts of a document are and how (and when) each is processed before proceeding to infinite detail like character classes (e.g.). Something heavily example- based, with real-world examples, would be helpful as well. I just find the language incredibly obscure and difficult to grok.


title: Need to change how \pagenote typesets the note number

text: I'm trying to get the `pagenote` package to display the note numbers as               \textbf{ \blue{ \big[ \roman{ notenum } \big] } }      I've redefined the `\notenumintext` as follows:               \renewcommand*{\notenumintext}[1]{\textbf{\blue \big[\roman{pagenote}\big]}}      and it displays exactly what I want. The .ent file appears to encode the correct information. But, a similar redefinition of `\noteenuminnotes` produces errors or strange output (like the correct format, but all the note numbers are the same). Right now, the document is written using the article document class, with `\usepackage[page]{pagenote}` loaded (among other things). Is this a simple case of not really understanding how the `renewcommand` works with counters? Yes, I've read the documentation many times as well as numerous discussion boards. Most of the documentations say things like, "this can be redefined" but don't tell you how to do it. Since I'm relatively new to this type of LaTeXing, it's a bit frustrating.


title: How to install my own .cls file on Debian?

text: I install texlive with a `.iso` file but not the Debian package. As on Ubuntu, I will do               mkdir -p $HOME/.texmf/tex/latex/amazing     sudo /usr/local/texlive/2013/bin/x86_64-linux/tlmgr conf texmf TEXMFHOME $HOME/.texmf     mv amazingbook.cls $HOME/.texmf/tex/latex/amazing     mktexlsr $HOME/.texmf      But this does not help on Debian, i.e. the `latex` can not find `amazingbook.cls`. What should I do then?


title: 3d axis and polyhedron with line segment towards origin

text: I would like to make a 3d plot containing the 3d axis and a convex polyhedron or better a Dodecahedron ![screenshot](http://i.stack.imgur.com/ewqmn.png) on the positive side for which one of its boundary edge points on its top is annotated e.g. `\hat{x}` "chosen" or "selected" and draw a line segment from that labeled point towards the origin. Then also highlight and annotate where this line segment intersects with the convex hull of the Dodecahedron. Would this be a nightmare to do using TikZ? btw what's the best way to learn TikZ once and for all? are there good books? I always end up consuming TikZ one way or another :( UPDATE: actually I need several plots around this same idea to illustrate in detail the behavior of an algorithm I need to document. I hope that by seeing how it is done for this case I will be able to generalize and do the others by myself ... though knowing how difficult it TikZ ... :(


title: how to control sections in ToC?

text: I do not want few subsections/ sub subsections to appear in my table of contents which might fill up unnecessary space. What command do i use to manage these sections to decide what appears and what doesn't appear on my Table


title: Index ordering when using math symbols

text: I'm making an index where certain entries start with the math symbols `$k$`, `$\mathcal{C}$`, `$\ast$-a...`. In the first two cases, I want them to appear in the index as if they start with k and c respectively. In the last case I want the index to ignore `$\ast$-` and treat the word as if it begins with the letter `a`. How might I go about doing that?


title: errors: esami package short answer questions

text: I am using the esami package to make a short answer exam. According to the documentation, I can use the following code in the variants file: This is the `eachtest.tex` file.               \begin{problem}     This is the question.     \begin{solution}     This is the answer.     \end{solution}     \end{problem}      This is the `problemtestfile.tex` that I am using to run it.               \documentclass[a4paper,UKenglish]{article}     \usepackage[shufflerandom,autopston,xyz,twocolumns,solutions,fillb]{esami}     \usepackage{pstricks}     \usepackage{pstricks-add}     \usepackage{pst-plot}          % +=============================+     % |         DEFINITIONS         |     % +=============================+          \def\examname{The name of the exam}                                                                      \def\numcompiti{1}%%% The number of the versions     \date{2013/3/22}%%% THE DATE IN THE FORMAT YYYY/MM/DD     \def\Data{\longdate}%%% or \shortdate: the date in the heading          \begin{document}     \testversioni          \pagestyle{esame}     \whiledo{\thevers<\numcompiti}{\stepvers          % +=============================+     % |       THE SEED              |     % +=============================+          \FPeval\seme{round((\thenomefile+(3*\thevers)):0)}          \randomi=\seme     \permuta          \section*{Practice Final Exam}     \begin{test}     \begin{questions}     \esercizi{eachtest}     \end{questions}     \end{test}          \closevers     }     \end{document}      Here is the error:               eachtest.tex     6     LaTeX Error: Something's wrong--perhaps a missing \item.          See the LaTeX manual or LaTeX Companion for explanation.     Type  H <return>  for immediate help.      ...                                                        l.6 \end{problem}          esami.sty     534     Overfull \hbox (5.79999pt too wide) in paragraph at lines 534--534     [][]      I don't understand what keeps causing it - maybe a package option I am missing? I tried to tag this question with the `esami` package, but no luck.


title: Subref with floatrow (without subcaption)

text: I have subfigures created with the `floatrow` package instead of the `subcaption` package. The latter is not loaded.               \begin{figure}[htbp]         \ffigbox[\FBwidth]         {\begin{subfloatrow}[2]         \ffigbox[\FBwidth]         {\caption{Cap1}\label{lab1}}         {Test1}         \ffigbox[\FBwidth]         {\caption{Cap2}\label{lab2}}         {Test2}         \end{subfloatrow}}         {\caption{Cap}         \label{lab}}     \end{figure}      The display is just as I want it. The main caption has the label "Fig. 1:", the subcaptions have "(a)" and "(b)". However, I miss the `\subref` macro of the `subcaption` package to directly link to subfigures. With `floatrow` I can only do `\ref{lab1}` yielding "1a". The former `\subref{lab1}` gave just "a" or even better "(a)" (to match the `labelformat=parens`). Can I do something similar with only `floatrow` and `caption` loaded? And if not, how can I redefine the `\ref` macro to match the `labelformat` and thus display "1(a)" instead of "1a"?


title: Align numbered and unnumbered entries in ToC (Koma-Script)

text: In Koma-Script I use `\addsec{.}` to add section without numbers. However, with respect to my ToC this gives undesirable results, as the unnumbered section-title is aligned with the beginning of the ToC line. How do I make unnumbered section aligned with numbered section in the ToC?               \documentclass{scrartcl}     \usepackage{tocstyle}     \usetocstyle{nopagecolumn}     \selecttocstyleoption{tocflat}          \begin{document}          \tableofcontents{}     \hrulefill     \section{First section}          \section{Second section}          \subsection{A subsection}          \addsec{A section which should not have a number}     \end{document}      ![output](http://i.stack.imgur.com/QyGya.png)


title: Force the expansion of a macro parameter without \edef or \xdef

text: Two days I am looking for a solution but I have no more idea. This is my problem. I'm trying to create a macro to automatically define new other macros to write references in a document. I want to create `\createrefmacro` which take one parameter (for example `Figure`). The `\createrefmacro` will create a new macro called `\refFigure` which will take one argument (the label of the reference) and an optional argument (I need an optional argument). This is an MWE which should reproduce my problem (my original macro contains more details and the MWE may seem stupid!).               \documentclass{article}       \makeatletter       \def\createrefmacro#1{%         \edef\macro{\csname ref#1\endcsname}%         \edef\macro@i{\csname ref#1@i\endcsname}%         \expandafter\gdef\macro{%           \expandafter\@testopt\macro@i{}%         }%         \expandafter\gdef\macro@i[##1]##2{#1~\ref{##2}}%       }       \makeatother       \createrefmacro{Figure}       \createrefmacro{Table}     \begin{document}       \begin{table}[htp]         \caption{First table}\label{tab1}       \end{table}       \begin{figure}[htp]         \caption{First figure}\label{fig1}       \end{figure}       \begin{figure}[htp]         \caption{Second figure}\label{fig2}       \end{figure}       \refFigure{fig1}\par       \refTable{tab1}\par       \refFigure{fig2}\par     \end{document}      With `\createrefmacro{Figure}` and `\createrefmacro{Table}`, I create the `\refFigure` and the `\refTable` macros. I write a small document with only 2 figures and 1 table then I try to insert corresponding references in the document. However, the result is not what I expect as can be seen below ![enter image description here](http://i.stack.imgur.com/axyQE.png) I tried few tricks with no success:   1. Replace `\gdef` with `\xdef`:      * In `\macro` but the compilation produce an error     * In `\macro@i` but the problem still happens   2. Use (plenty of) `\expandafter` to force the expansion of `#1` in `\macro@i` but I don't really know how and where to use it in this particular case. I know the existence of packages like `varioref` and the `\labelformat` macro which should do the job in a better way. However, I need a solution which does not use external packages because of submissions as a scientific article (and I'm also very curious of the solution of this tricky problem!).


title: Removing the quotations marks from the bibliography using harvard style (agsm)

text: I'm pretty new to using LaTeX but have so far found it fairly intuitive and am currently using it to write my dissertation. I am using the `harvard` and `natbib` packages to cite and create my bibliography. I am using the `agsm` style to create the bibliography and end up with this: > Leopold, L. & Maddock, T. (1953), ‘The hydraulic geometry of stream channels > and some physiographic implications’, U.S. Geological Survey Professional > Paper 252, 1– 56. As opposed to what I need being this: > Leopold, L. & Maddock, T. (1953), The hydraulic geometry of stream channels > and some physiographic implications, U.S. Geological Survey Professional > Paper 252, 1– 56. I need to remove the quotation marks at the start and end of the article name but I'm not sure how. The BibTeX code for the reference is               @article{leopold1953,      Author = {Leopold, L.B. and Maddock, T.},      Date-Added = {2012-03-10 11:33:51 +0000},      Date-Modified = {2012-03-10 12:14:58 +0000},      Journal = {U.S. Geological Survey Professional Paper},      Lccn = {gs53000079},      Pages = {1-56},      Series = {Professional paper},      Title = {The hydraulic geometry of stream channels and some physiographic implications},      Volume = {252},      Year = {1953},      Bdsk-Url-1 = {books.google.co.uk/books?id=cA%5C_WYgEACAAJ}     }


title: Eso-pic and data-tool

text: Csv files can be easier to prepare for the person who is not used to LaTeX syntax. I would like to use a csv file containing * * * ## Id, myauthor, mydate, myaddress >   1. Sebastian, 12.12.2012, XYZ road, XYZ city >   2. Rose, 12.12.2013, XYZ road, abc city > * * * I have to define a command in such a way that if I provide input of Id, the respective fields in following example should be automatically populated.               \documentclass{article}     \usepackage{eso-pic}     \usepackage{fancyhdr}     \usepackage{blindtext} % just for the example     \usepackage[headsep=3cm,top=5cm]{geometry}     \AddToShipoutPicture{%       \AtTextUpperLeft{%         \makebox(420,75)[lt]{%           \footnotesize%           \begin{tabular}{@{}*{3}{p{4.5cm}}@{}}%           \textbf{Author}\newline\myauthor&%           \textbf{Date of birth}\newline\mydate&%           \textbf{Address}\newline\myaddress%           \end{tabular}%     }}}     \pagestyle{fancy}          \newcommand{\myauthor}{user34083}     \newcommand{\mydate}{December 26, 1997}     \newcommand{\myaddress}{26 Washington Ave., Manhattan, New York.\newline United States of America}          \begin{document}          \blinddocument % just for the example          \end{document}


title: Natbib+harvard.bst: papers in same year listed in the wrong order

text: I have a bibliography in which a particular author wrote two papers in the same year. Bibtex is sorting them alphabetically by title, but I want them listed chronologically. (So in the example below 'universal grammar' should precede 'English as a formal language'.) What's the appropriate way to flip the order? MWE:               \documentclass{article}     \usepackage{natbib}     \begin{document}          ... formal semantics in the  Montagovian tradition \citep{montague1970aug,montague1970befl,montague1973ptq}.           \bibliographystyle{harvard}     \bibliography{test}     \end{document}      This generates the text 'formal semantics in the Montagovian tradition (Montague, 1970b,a, 1973)' whereas I actually want '1970a,b,1973'. test.bib file for MWE:               @incollection{montague1973ptq,       title={The proper treatment of quantification in ordinary {English}},       author={Montague, Richard},       booktitle={Approaches to natural language},       editor={Hintikka, K. Jaakko J. and Moravcsik, Julius M.E. and Suppes, Patrick},       pages={221--242},       year={1973},       publisher={Dordrecht}     }          @article{montague1970aug,       title={Universal grammar},       author={Montague, Richard},       journal={Theoria},       volume={36},       number={3},       pages={373--398},       year={1970},       publisher={Blackwell Synergy}     }          @incollection{montague1970befl,       title={English as a formal language},       author={Montague, Richard},       booktitle={Linguaggi nella Societa e nella Tecnica},       editor={Visentini, Bruno and others},       publisher={Edizioni di Comunità},       pages={189--224},       year={1970}     }


title: Overwriting environment style

text: How can I change the style of an element in LaTeX ? I would like to do some basic modifications on some environments. For example changing the text size in `quotation`, margins in `verbatim` or the line spacing in `itemize` blocks. I want the change to be made on every block of the document. How can I rewrite some style definitions ?


title: Center parts in toc with tocloft

text: I'm trying to create a toc in a large Latex document which uses the KOMA script. In the toc I would like to center the parts and remove all other components (pagenumber, partnumber). I use tocloft (a hard requirement for other reasons). While I managed to remove the pagenumber, the partnumber is still there and the parts are very much on the right site instead of being centered. A simplified example is:               \documentclass{scrbook}     \usepackage[ngerman]{babel}          \usepackage{lipsum}          \usepackage{tocloft}     \renewcommand{\cftpartfont}{\hfill\Large\bfseries}     \renewcommand{\cftpartaftersnum}{\hfill}     \addtocontents{toc}{\cftpagenumbersoff{part}}          \begin{document}     \tableofcontents     \part{A}     \section{a}     \lipsum     \part{B}     \section{b}     \lipsum          \end{document}      I have adapted the commands for the centering from an example of the tocloft manual, where > \renewcommand{\cftZtitlefont}{\hfill\Large\bfseries} together with > \renewcommand{\cftafterZtitle}{\hfill} will give a centered Large bold > title. was used to center the title (instead of the parts). So my question, how can I center the parts and remove the partnumber?


title: How to understand and write LaTeX code?

text: LaTeX is like a language. In order to write LaTeX code I have to understand the _"word"_ and the _"sentences structure"_. I have searched on wiki, some LaTeX books, but they just give the LaTeX command, not how to write a LaTeX code for some specific purpose or to understand the LaTeX code. Here is one example:               \renewenvironment{svgraybox}%            {\fboxsep=12pt\relax             \begin{shaded}%             \list{}{\leftmargin=12pt\rightmargin=2\leftmargin\leftmargin=\z@\topsep=\z@\relax}%             \expandafter\item\parindent=\svparindent             \hskip-\listparindent}%            {\endlist\end{shaded}}%     %     \renewenvironment{svtintedbox}%            {\fboxsep=12pt\relax             \begin{tinted}%             \list{}{\leftmargin=12pt\rightmargin=2\leftmargin\leftmargin=\z@\topsep=\z@\relax}%             \expandafter\item\parindent=\svparindent             \relax}%            {\endlist\end{tinted}}%     %     }}     %     \let\SVMonoOpt\@empty      I do not know what is `\z@`, what is `\relax`, what is `\fboxsep` ... and if I want to design my LaTeX file in my own form, I know that I have to understand many other things. Note that I can write simple LaTeX enviroment in mathematics (like the matrix, align, enviroment) but it does not help me to understand the above code. So, what could I do? What book should I read? Or what programming language should I learn?


title: Nested matrices with aligned columns and rows

text: I'm trying to represent "matrices" with more than two dimensions, like the Riemann curvature tensor or Christoffel symbols, using nested matrices. I still don't know if this can help working with these objects (and that's not really relevant to this topic anyway), but before judging I'd like to see how it looks on a computer screen. The idea is to write a vector of matrices for a 3-indices matrix, a matrix of matrices for a 4-indices matrix and so on. This is not difficult in principle:               \documentclass{article}     \usepackage{amsmath}          \begin{document}          \[     \Gamma^{\sigma}_{\mu \nu} = \begin{pmatrix}         \begin{pmatrix}             0 & 0 & 0 \\             0 & -r & 0 \\             0 & 0 & -r \sin^2(\vartheta)         \end{pmatrix} \\         \begin{pmatrix}             0 & \frac{1}{r} & 0 \\             \frac{1}{r} & 0 & 0 \\             0 & 0 & - \sin(\vartheta) \cos(\vartheta)         \end{pmatrix} \\         \begin{pmatrix}             0 & 0 & \frac{1}{r} \\             0 & 0 & \frac{1}{\tan(\vartheta)} \\             \frac{1}{r} & \frac{1}{\tan(\vartheta)} & 0         \end{pmatrix}     \end{pmatrix}     \]          \end{document}      but the result looks really ugly: ![enter image description here](http://i.stack.imgur.com/5Bvyb.png) That's what I wanted, but not how I wanted it. Is there a way to align columns and rows of different matrices? Or, alternatively, is there a way to insert internal parentheses that span through multiple rows in a big matrix with all the components?


title: LaTeX tokenizing

text: With LaTeX macro               \newcommand{\CH}[2]{#1\choose#2}      and input               \CH63=20      my hope was to get the equivalent of               {6\choose3}=20      but I get               {6\choose3=20}      instead. I know how to fix the text to get what I want, but I really want to change the macro. Any ideas? And if you know, where did you find it, since I spent a considerable time to find an online answer and would like to have access to a document that can provide answers to questions like this one.


title: Where can I find the official version of MiKTeX to download safely?

text: I just tried downloading a newer version of MiKTeX from the MiKTeX site and a huge amount of sketchy junk, including shop to win and blekko seemed to come with it, scaring me off. Is this safe? And can anyone tell me what is going on?


title: Style of Section Headings in LNCS

text: I am using the LNCS-Style, documentsclass llncs and there is no possibilty to use chapters. Actually when adding a section it looks some kind of this: ![enter image description here](http://i.stack.imgur.com/NhxES.png) What i want to do is to change just the style of this main sections and leave any other nested sections below alone (subsections, subsubsections, paragraphs ...). It should look some kind of this: ![enter image description here](http://i.stack.imgur.com/iE0QA.png) What i tried was renewing the section command by doing this:               \renewcommand{\thesection}{Chapter \arabic{section}}      That was the only thing that came in my mind but this actually not what i need, as it only adds a text before the section number and affects even the subsections and every section below.


title: Positioning a node horizontally aligned and below others

text:
Using tikz 3.0.0, I want to create the following diagram ![commutative diagram1](http://i.stack.imgur.com/SItom.png) which I have so far achieved by manually positioning the “G” in the last row:               \begin{center}         \begin{tikzpicture}             \node (A) {$(G×G)×G$};             \node (B) [right=of A] {$G×(G×G)$};             \node (C) [below left=of A] {$G×G$};             \node (D) [below right=of B] {$G×G$};             \node (E) at (1.5,-3) {$G$};             \draw[double equal sign distance] (A) -- node[above]{$\sim$} (B);                  \draw[->] (A) -- node[above left]{\small $μ × \id$} (C);             \draw[->] (B) -- node[above right]{\small $\id × μ$} (D);             \draw[->] (C) -- node[above]{\small $μ$} (E);             \draw[->] (D) -- node[above]{\small $μ$} (E);         \end{tikzpicture}     \end{center}      Can I do this without maually setting “G” `at (1.5,-3)` using positioning? On a related note, I tried to do the same with {tikz-cd} and got: ![commutative diagram2](http://i.stack.imgur.com/3mTQD.png) using the following code:               \begin{displaymath}         \begin{tikzcd}
             & (G × G) × G \ar[dl, "μ × \id"] \ar[rr, equal, "\sim"] & & G × (G × G) \ar[dr, "\id × μ"] & \\
             G × G \ar[drr, "μ"] & & & & G × G \ar[dll, "μ"] \\
              & & G & &
         \end{tikzcd}
     \end{displaymath}      Can I somehow achieve a picture without an unnecessarily stretched equal sign, that is a picture more like the one above, but using {tikz-cd}? I’m using TeXLive, version 2013.


title: How do I number appendix longtables and include them in the *ToC*?

text: I am writing my PhD dissertation. I have many appendices (like 6?), mostly tables. As it happens automatically for tables and figures, I'd like to get a label plus progressive number before I define the title of the appendix on the top of the appendix page. Something like Appendix 1: Bla bla bla. Also, I'd like my appendix titles to be included in the ToC. This is what I have:               \documentclass[11pt,a4paper,oneside]{report}     \usepackage[toc,page]{appendix}          \begin{document}          \tableofcontents     \addcontentsline{file}{sec_unit}{entry}          \begin{appendices}          \appendix{Cities Coordinates\label{appendix:Cities Coordinates}}     \begin{longtable}{ l l r r}     \toprule     \textsc{County}&\textsc{City}&\textsc{Latitude}&\textsc{Longitude}\\ \midrule     \endfirsthead     \caption[]{(continued)}\\     \toprule     \textsc{County}&\textsc{City}&\textsc{Latitude}&\textsc{Longitude}\\ \midrule     \endhead     \bottomrule     \endlastfoot     Alameda&Alameda&-122.24&37.76\\     &Albany&-122.29&37.88\\     &Berkeley&-122.27&37.87\\     &Dublin&-121.93&37.70\\     &Hayward&-122.08&37.66\\     &Emeryville&-122.28&37.83\\     &Oakland&-122.27&37.80\\     &Piedmont&-122.23&37.82\\     &San Leandro&-122.15&37.72\\     &Union City&-122.04&37.59\\     \end{longtable}     \end{document}      * * * I still have some problems with the appendices:   1. In the ToC I see only three appendixes represented, but I am providing four instead;   2. I don't know where to type the title of my appendices so that it comes out uniformly, no matter if the appendix is a table or a list of examples;    3. I would like the title of my appendix in the landscaped page to be at the top of the page. Thank you in advance. And yes, I use **longtables** because I have a long list of data to display.               \documentclass[11pt,a4paper,oneside]{report}     \usepackage{array}     \usepackage{covington}     \usepackage[danish,english]{babel}     \usepackage{titlesec}     \usepackage[a4paper]{geometry}     \geometry{includefoot=false, heightrounded=true, top=4.5cm, bottom=6cm, left=4.7cm, right=4.7cm}      \usepackage[toc,page]{appendix}     \usepackage{longtable}     \usepackage{caption}     \newif\ifappendix % snippet appendix     \makeatletter     \def\LT@c@ption#1[#2]#3{%       \LT@makecaption#1\fnum@table{#3}%       \def\@tempa{#2}%       \ifx\@tempa\@empty\else          {\let\\\space          \addcontentsline{\ifappendix toc\else lot\fi}{table}{\protect\numberline{\thetable}{#2}}}%       \fi}     \makeatother     \usepackage{multirow}     \usepackage{morefloats}     \usepackage{booktabs}     \newcolumntype{R}{>{\raggedleft\arraybackslash}p{2cm}}     \setlength\belowcaptionskip{1\baselineskip}      \usepackage{lscape}           \begin{document}          \pagenumbering{arabic}       \tableofcontents      \addcontentsline{file}{sec_unit}{entry}          \chapter{How Do I Make a Nice Appendix?}          \section{Please Advise}          Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.           \begin{appendices}     \appendixtrue          \setcounter{table}{0}     \renewcommand*{\thetable}{A.\arabic{table}}          \begin{longtable}{ l l r r}     \caption{text text\label{appendix:this is just the table caption. I would like this to be something like: Appendix A.1: bla bla bla}}\\     \toprule     \textsc{text}&\textsc{text}&\textsc{text}&\textsc{text}\\ \midrule     \endfirsthead     \caption[]{(continued)}\\     \toprule     \textsc{text}&\textsc{text}&\textsc{text}&\textsc{text}\\ \midrule     \endhead     \bottomrule     \endlastfoot     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     text&text&123&123\\     &text&123&123\\     &text&123&123\\     \end{longtable}          \newpage     \appendixtrue     \setcounter{table}{1}     \renewcommand*{\thechapter}{\arabic{chapter}}     \begin{landscape}     \begin{longtable}{l l l l}     \caption{this is a table caption that I would like to print at the top of my page\label{appendix:this is a table caption that I would like to print at the top of my page}}\\     \toprule     \textsc{text}&\textsc{text}&\textsc{text}&\textsc{website}\\      \midrule     \endfirsthead     \caption[]{(continued)}\\     \toprule     \textsc{text}&\textsc{text}&\textsc{text}&\textsc{website}\\      \midrule     \endhead     \bottomrule     \endlastfoot     text&text&text&www.nytimes.com\\     text&text&text&www.nytimes.com\\     text&text&text&www.nytimes.com\\     \end{longtable}     \end{landscape}          \newpage     \appendixtrue     \setcounter{table}{2}     \renewcommand*{\thetable}{A.\arabic{table}}     \begin{landscape}     \begin{longtable}{l l l r r r r r}     \caption{text\label{appendix:text3}}\\     \toprule     \textsc{text}&\textsc{text}&\textsc{text}&\textsc{text}&number&number&number&number\\     \midrule     \endfirsthead     \caption[]{(continued)}\\     \toprule     \textsc{text}&\textsc{text}&\textsc{text}&\textsc{text}&number&number&number&number\\     \midrule     \endhead     \bottomrule     \endfoot     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\     text&text&text&text&number&number&number&number\\          \end{longtable}     \end{landscape}          \newpage     \appendixtrue     \setcounter{table}{3}     \renewcommand*{\thetable}{A.\arabic{table}}     \appendix{I would like this to be Appendix A.4: bla bla bla\label{appendix:I would like this to be Appendix A.4: bla bla bla}}     \begin{examples}     \item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \label{ex:Lorem}     \item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\label{ex:ipsum}     \end{examples}          \end{appendices}          \end{document}


title: How to change one thing to change all

text: I have the following but when I change scale, I have to change all images. Is there a better way so that I can change only one place? I read about command/macro but not sure how to use it in this case.               \documentclass[fleqn]{article}     \usepackage{graphicx}     \begin{document}     \begin{enumerate}     \item     \includegraphics[scale=0.6,valign=t]{images/image13}     \item     \includegraphics[scale=0.6,valign=t]{images/image14}     \item     \includegraphics[scale=0.6,valign=t]{images/image18}     \item         \includegraphics[scale=0.6,valign=t]{images/image19}     \end{enumerate}     \end{document}


title: Change distance between nodes in tikz graph

text: I am attempting to do this, but I cannot seem to find the correct syntax for it in LaTeX. Here is what I have:               \documentclass[12pt]{article}     \usepackage[english]{babel}     \usepackage{tikz}          \usetikzlibrary{graphdrawing}     \usetikzlibrary{positioning,graphs}     \usegdlibrary{layered}     \begin{document}     \begin{tikzpicture}[baseline]                     \begin{graph}[layered layout,nodes={draw,circle, node distance=10cm}]                         {1->[edge label=bob, node distance=3cm]2};                     \end{graph}                 \end{tikzpicture}     \end{document}      None of the `node distance` commands seem to have an impact Any ideas?


title: Different colors for default and language-specific listings

text: I'm generating pdf documents using knitr and pandoc. The conversion is mostly automated from R markdown -> markdown -> latex -> pdf. However, my documents combine R source code and its output, and I would like to differentiate the two kinds of code visually. As an example, here's the generated tex:               \documentclass[]{article}          \usepackage{listings}     \usepackage[usenames,dvipsnames]{color}          \lstset{backgroundcolor=\color[gray]{0.95},     frame=single,columns=fixed,basicstyle=\ttfamily,     keepspaces=true,showstringspaces=false,numbers=none}          \begin{document}          Here's some regular text.          \begin{lstlisting}[language=R]     summary(cars)     \end{lstlisting}          \begin{lstlisting}     ##      speed           dist         ##  Min.   : 4.0   Min.   :  2       ##  1st Qu.:12.0   1st Qu.: 26       ##  Median :15.0   Median : 36       ##  Mean   :15.4   Mean   : 43       ##  3rd Qu.:19.0   3rd Qu.: 56       ##  Max.   :25.0   Max.   :120     \end{lstlisting}          \end{document}      In the output pdf, both of the listings in this example are shaded gray. I'd like to have only one of them shaded, either the language=R block or the other one. I can easily add code to the header with templates, but modifying the individual blocks is not practical for auto-generated documents. Is there some way to tell listings to apply one colour to an environment with a known language (in this case R), and a different (or no) colour to an environment with no language set? _CLARIFICATION_ As the code is generated by other programs, I can't easily modify anything after the '\begin{document }' line. Is there a solution that only modifies the header? I'm trying to avoid manually altering the text after writing the initial .Rmd file. **Follow-up** So far I haven't found a way to do what I need using the built- in features of knitr and pandoc. The closest I've come is post-processing the pandoc-produced tex file to add the style options I need to implement the answer provided by @GonzaloMedina.               #!/bin/bash     fullname=$(basename "$1")     extension="${fullname##*.}"     filename="${fullname%.*}"     pandoc $fullname -o $filename.tex --template=ty --listings     sed -i 's/\\begin{lstlisting}\[language=R\]/\\begin{lstlisting}[language=R,style=myRstyle]/g' $filename.tex     pdflatex $filename.tex      From the command line, running this script as:               convert.sh my-source.md      This appends the style property to all the chunks with the language option set to R. The style itself is defined in `~/.pandoc/templates/ty.latex`. The basic layout of that file can be crimped from the output of `pandoc -D latex`, and should include `\lstdefinestyle{myRstyle}{...}`, as in Gonzalo's example. The script continues on to produce the pdf output, so now the problem is mostly solved. It will be less portable than something that uses pandoc or knitr directly, instead of sed, but maybe that's not possible.