title: How to implement (low-level) arrays in TeX

text: **Update:** I have revised my question based on the comment by Bruno Le Floch and some further research. * * * As some may know, I'm implementing a huge TeX macro package which has to do a lot of internal computations, and hence will give a lot less overall performance "per page" than, for instance, your usual LaTeX document. Looking for quick wins in enhancing performance, I'm currently investigating what are the most performant ways to do some really basic computations in TeX. One thing I'm using a lot, are _array-like_ structures where large amounts of values are stored in main memory, accessible by one or several numeric keys. So my question here is basically: **What is the best way to implement a one- or multi-dimensional array in TeX, concentrating on numerical access keys?** ## What I know so far Currently, to store `<value>` in array `<myarray>` with key `<key>`, I basically do               \expandafter\def\csname<myarray>@<key>@DocScape\endcsname{<value>}      (assuming `<key>` is in a form which can go in a cs name). Of course, this doesn't give a true random-access, compact array structure, but instead uses the internal hash table in the hope to get good performance for inserting a new array element and "almost" _O(1)_ access to retrieve array elements. Additionally, I can't imagine any other way of getting comparable performance with a TeX implementation. Hence, for the moment I'm looking into ways of improving the performance of this basic technique. ## Testing the raw hash performance I've heard several times now that TeXs hashing algorithm for cs names is not so good, so one performance problem could be to get a lot of hash conflicts, leading to a lot worse performance than _O(1)_ , but I haven't looked into the sources, so I don't know in what way exactly it is bad. Also, I haven't found any precise information on this subject on this site. If hash performance is bad, I can imagine the following things which may influence the overall performance of the array construct:   1. Total length of cs name   2. Length of a "constant" prefix before the "significant part" (i.e. the encoding of `<key>`).   3. The way `<key>` is encoded. To test what form of constructing the cs name for array elements gives the best performance, I made the following test suite:               \input random          % Three different implementations of a "hash array" with numerical     % keys using different key encodings.          \input numhasharray.tex          \input hashnumhasharray.tex          \input codenumhasharray.tex          \newcount\iter     \newcount\rcount     \def\gobble#1{}                    % A macro for setting up one experiment to test the "raw hash performance".          \def\mkhashexperiment#1#2#3#4#5%     {%       \iter0            \immediate\openout2=#1-setup.tex            \immediate\write2{\noexpand\message{starting test "#1"; size #2; prefix "#3";}}       \immediate\write2{\noexpand\message{postfix "#4"; coding \string\string\string#5}}%            \loop        \ifnum\iter<#2         \advance\iter1         \immediate\write2         {%           \noexpand\expandafter\noexpand\def           \noexpand\csname#3#5\iter#4\noexpand\endcsname{\number\iter}%         }%       \repeat            \immediate\closeout2 %            \iter0            \immediate\openout2=#1.tex            \immediate\write2{\expandafter\gobble\string\\input\space#1-setup}%            \immediate\write2{\expandafter\gobble\string\\newcount\string\mycount}%       \loop        \ifnum\iter<#20         \advance\iter1         \setrannum{\rcount}{1}{#2}         \immediate\write2         {%           % What is the most performant way to "just retrieve" the array           % value without causing any further computation cost?           \noexpand\mycount           \noexpand\csname#3#5\rcount#4\noexpand\endcsname\relax         }%       \repeat            \immediate\write2{\expandafter\gobble\string\\bye}%       \immediate\closeout2 %            \immediate\write1{time tex #1;}     }               % A macro for setting up one experiment to test the performance of an     % array implementation.          \def\mkarrayexperiment#1#2#3#4#5%     {%       \iter0            \immediate\openout2=#1-setup.tex            \immediate\write2{\noexpand\message{starting test "#1"; size #2;       array implementation "#3"}}%            \immediate\write2{\expandafter\gobble\string\\input\space#3}%            \loop        \ifnum\iter<#2         \advance\iter1         \immediate\write2         {%           \string#4{foo}{\number\iter}{\number\iter}%         }%       \repeat            \immediate\closeout2 %            \iter0            \immediate\openout2=#1.tex            \immediate\write2{\expandafter\gobble\string\\input\space#3}%            \immediate\write2{\expandafter\gobble\string\\input\space#1-setup}%            \immediate\write2{\expandafter\gobble\string\\newcount\string\mycount}%       \loop        \ifnum\iter<#20         \advance\iter1         \setrannum{\rcount}{1}{#2}         \immediate\write2         {%           % What is the most performant way to "just retrieve" the array           % value without causing any further computation cost?           \noexpand\mycount\string#5{foo}{\number\rcount}\relax         }%       \repeat            \immediate\write2{\expandafter\gobble\string\\bye}%       \immediate\closeout2 %            \immediate\write1{time tex #1;}     }               % Number of array entries to generate; 10x this number of random retrievals     % is generated.          \def\experimentsize{100000}          % Execute this sh script to run the tests.          \immediate\openout1=testhash.sh          \immediate\write1{(}               % Testing the performance of the internal hash table.          % The usual way of implementing an array: Just put the access key in     % the name directly as a \number.           \mkhashexperiment{testhash1}{\experimentsize}{pre}{}{\number}     \mkhashexperiment{testhash2}{\experimentsize}{}{post}{\number}     \mkhashexperiment{testhash3}{\experimentsize}{verylongprefixtostresshashtable}{}{\number}     \mkhashexperiment{testhash4}{\experimentsize}{}{verylongprefixtostresshashtable}{\number}     \mkhashexperiment{testhash5}{\experimentsize}{verylong}{prefixtostresshashtable}{\number}     \mkhashexperiment{testhash6}{\experimentsize}{verylongprefixto}{stresshashtable}{\number}               % Encoding provided by Bruno le Floch to optimise number hashing.          \mkhashexperiment{testhash19}{\experimentsize}{pre}{}{\hashnumber}     \mkhashexperiment{testhash20}{\experimentsize}{}{post}{\hashnumber}     \mkhashexperiment{testhash21}{\experimentsize}{verylongprefixtostresshashtable}{}{\hashnumber}     \mkhashexperiment{testhash22}{\experimentsize}{}{verylongprefixtostresshashtable}{\hashnumber}     \mkhashexperiment{testhash23}{\experimentsize}{verylong}{prefixtostresshashtable}{\hashnumber}     \mkhashexperiment{testhash24}{\experimentsize}{verylongprefixto}{stresshashtable}{\hashnumber}               % Best performance I found so far.          \mkhashexperiment{testhash25}{\experimentsize}{pre}{}{\mynumcode}     \mkhashexperiment{testhash26}{\experimentsize}{}{post}{\mynumcode}     \mkhashexperiment{testhash27}{\experimentsize}{verylongprefixtostresshashtable}{}{\mynumcode}     \mkhashexperiment{testhash28}{\experimentsize}{}{verylongprefixtostresshashtable}{\mynumcode}     \mkhashexperiment{testhash29}{\experimentsize}{verylong}{prefixtostresshashtable}{\mynumcode}     \mkhashexperiment{testhash30}{\experimentsize}{verylongprefixto}{stresshashtable}{\mynumcode}               % Testing the performance of different array implementations.          % Hash array with simple numerical keys.          \mkarrayexperiment{testnumhasharray}{\experimentsize}{numhasharray}{\numhashstore}{\numhashretrieve}          % Hash array with encoding provided by Bruno le Floch to optimise     % number hashing.           \mkarrayexperiment{testhashnumhasharray}{\experimentsize}{hashnumhasharray}{\hashnumhashstore}{\hashnumhashretrieve}          % Hash array with "hash spread" encoding.          \mkarrayexperiment{testcodenumhasharray}{\experimentsize}{codenumhasharray}{\codenumhashstore}{\codenumhashretrieve}               \immediate\write1{) \string&> testhash.log}          \immediate\closeout1 %          \bye      To generate the tests, you need the following implementation files for different hash-based array variants: `numhasharray.tex`               % The most basic "hash array" for numeric keys:      % just use the number as a key.          \def\numhashstore#1#2#3{\expandafter\def\csname\number#2\string_#1\string_nh\endcsname{#3}}     \def\numhashretrieve#1#2{\csname\number#2\string_#1\string_nh\endcsname}      `hashnumhasharray.tex`               % This encoding is by Bruno Le Floch, directly constructed to optimise     % hash performance.          \def\step#1{#1---\step}     \def\endstep#1\step{}     \def\hashnumber#1{\expandafter\step \number#1 \endstep}               \def\hashnumhashstore#1#2#3{\expandafter\def\csname\hashnumber{#2}\string_#1\string_hnh\endcsname{#3}}     \def\hashnumhashretrieve#1#2{\csname\hashnumber{#2}\string_#1\string_hnh\endcsname}      `codenumhasharray.tex`               % My own encoding for numerical keys, hoping to spread out hash     % codes. In particular, I'm trying to get different cs name     % lengths. I'm indepted to Bruno Le Floch for the neat way of ending     % the recursion without an \if construct.          \expandafter\def\csname numkeya0\endcsname{a1Y@}     \expandafter\def\csname numkeya1\endcsname{b}     \expandafter\def\csname numkeya2\endcsname{c2}     \expandafter\def\csname numkeya3\endcsname{dZ}     \expandafter\def\csname numkeya4\endcsname{e3'}     \expandafter\def\csname numkeya5\endcsname{f}     \expandafter\def\csname numkeya6\endcsname{g4!}     \expandafter\def\csname numkeya7\endcsname{h}     \expandafter\def\csname numkeya8\endcsname{i5-}     \expandafter\def\csname numkeya9\endcsname{j"}     \expandafter\def\csname numkeya;\endcsname\myencodeb{}          \expandafter\def\csname numkeyb0\endcsname{k6}     \expandafter\def\csname numkeyb1\endcsname{l;}     \expandafter\def\csname numkeyb2\endcsname{m7/}     \expandafter\def\csname numkeyb3\endcsname{n}     \expandafter\def\csname numkeyb4\endcsname{o8}     \expandafter\def\csname numkeyb5\endcsname{p(:}     \expandafter\def\csname numkeyb6\endcsname{q9}     \expandafter\def\csname numkeyb7\endcsname{r}     \expandafter\def\csname numkeyb8\endcsname{s0(}     \expandafter\def\csname numkeyb9\endcsname{t,}     \expandafter\def\csname numkeyb;\endcsname\myencodec{}          \expandafter\def\csname numkeyc0\endcsname{uO}     \expandafter\def\csname numkeyc1\endcsname{v)}     \expandafter\def\csname numkeyc2\endcsname{wP}     \expandafter\def\csname numkeyc3\endcsname{x<}     \expandafter\def\csname numkeyc4\endcsname{yQ=}     \expandafter\def\csname numkeyc5\endcsname{z}     \expandafter\def\csname numkeyc6\endcsname{AR}     \expandafter\def\csname numkeyc7\endcsname{B?>}     \expandafter\def\csname numkeyc8\endcsname{CS}     \expandafter\def\csname numkeyc9\endcsname{D}     \expandafter\def\csname numkeyc;\endcsname\myencoded{}          \expandafter\def\csname numkeyd0\endcsname{ET[|}     \expandafter\def\csname numkeyd1\endcsname{F}     \expandafter\def\csname numkeyd2\endcsname{GU}     \expandafter\def\csname numkeyd3\endcsname{H]}     \expandafter\def\csname numkeyd4\endcsname{IV}     \expandafter\def\csname numkeyd5\endcsname{J}     \expandafter\def\csname numkeyd6\endcsname{KW*}     \expandafter\def\csname numkeyd7\endcsname{L}     \expandafter\def\csname numkeyd8\endcsname{MX}     \expandafter\def\csname numkeyd9\endcsname{N+}     \expandafter\def\csname numkeyd;\endcsname\myencodea{}          \def\mynumcode#1{\expandafter\myencodea\number#1;}     \def\myencodea#1{\csname numkeya#1\endcsname\myencodeb}     \def\myencodeb#1{\csname numkeyb#1\endcsname\myencodec}     \def\myencodec#1{\csname numkeyc#1\endcsname\myencoded}     \def\myencoded#1{\csname numkeyd#1\endcsname\myencodea}          \def\codenumhashstore#1#2#3{\expandafter\def\csname\mynumcode{#2}\string_#1\string_cnh\endcsname{#3}}     \def\codenumhashretrieve#1#2{\csname\mynumcode{#2}\string_#1\string_cnh\endcsname}      This will generate a couple of TeX files and a shell script to run a number of tests for comparing performance of different cs name constructs.               \mkhashexperiment{testhash1}{100000}{pre}{post}{\number}      generates a TeX file `testhash1.tex` creating an an array construct with `100000` successively numbered entries and `1000000` random retrievals where the cs name is               \csname pre\number<key>post\endcsname      for `<key>`s between `1` and `100000`. Comparing the running times of the tests `testhash1` to `testhash6` above I get on my laptop (quoting from `testhash.log`):               starting test "testhash1"; size 100000; prefix "pre";     postfix ""; coding \number) )     real    0m4.642s     user    0m4.296s     sys 0m0.068s          starting test "testhash2"; size 100000; prefix "";     postfix "post"; coding \number) )     real    0m3.827s     user    0m3.748s     sys 0m0.036s          starting test "testhash3"; size 100000; prefix "verylongprefixtostresshashtable     "; postfix ""; coding \number) )     real    0m16.614s     user    0m16.265s     sys 0m0.160s          starting test "testhash4"; size 100000; prefix "";     postfix "verylongprefixtostresshashtable"; coding \number) )     real    0m6.317s     user    0m6.176s     sys 0m0.072s          starting test "testhash5"; size 100000; prefix "verylong";     postfix "prefixtostresshashtable"; coding \number) )     real    0m8.971s     user    0m8.789s     sys 0m0.116s          starting test "testhash6"; size 100000; prefix "verylongprefixto";     postfix "stresshashtable"; coding \number) )     real    0m13.337s     user    0m12.753s     sys 0m0.112s      (Note that these are simple system timing results on my laptop computer, so they are probably slightly skewed by other processes on the system. Still the numbers are basically reproducible on repetition.) The first (maybe surprising) result is that this amount of variation alone creates a huge difference in overall performance, with a difference of up to a factor **4** in running time. If it was possible to discount the fixed amount of additional processing (I used a counter assignment to access the array value), the difference would probably be much, much larger! Now I heard that hash performance is particularly bad for sequences of digits, so `\number` is possibly not a good idea for encoding the array access key. Bruno Le Floch gave a comment in which he describes how to optimize number representation for hashing. This is implemented in the macro `\hashnumber` and tested by the test cases `testhash19` to `testhash24`. The results:               starting test "testhash19"; size 100000; prefix "pre";     postfix ""; coding \hashnumber) )     real    0m2.395s     user    0m2.280s     sys 0m0.052s          starting test "testhash20"; size 100000; prefix "";     postfix "post"; coding \hashnumber) )     real    0m2.483s     user    0m2.260s     sys 0m0.048s          starting test "testhash21"; size 100000; prefix "verylongprefixtostresshashtabl     e"; postfix ""; coding \hashnumber) )     real    0m4.173s     user    0m3.740s     sys 0m0.056s      [snip] This gives a significantly better result than when using `\number`:   * The best performance is almost double that of `\number` (so **8** times better than the worst for `\number`).   * The "spread out" of performances between different cs name constructions is almost negligible; _even the worst performance for`\hashnumber` is better than the best performance for `\number`_. Of course, I'm intrigued how far this could still be enhanced by choosing a more clever encoding, but I have no clue how to go about this systematically. In the hope to "spread out" hash keys for encoded numbers a bit more I made an encoding function myself (`\mynumcode`; see test suite above). It will use a lot of different characters, produce different key lengths and avoid repetitions, which hopefully leads to a better distribution of hash keys. Using this encoding, I get the following running times:               starting test "testhash25"; size 100000; prefix "pre";     postfix ""; coding \mynumcode) )     real    0m2.194s     user    0m1.920s     sys 0m0.016s          starting test "testhash26"; size 100000; prefix "";     postfix "post"; coding \mynumcode) )     real    0m2.089s     user    0m2.020s     sys 0m0.040s          starting test "testhash27"; size 100000; prefix "verylongprefixtostresshashtabl     e"; postfix ""; coding \mynumcode) )     real    0m3.594s     user    0m3.008s     sys 0m0.036s      [snip] You see that the timing results are slightly better than for `\hashnumber`, but not significantly so. So probably this is getting near optimal (for the hashing implementation of the TeX engine). As the tests reported above are as near to testing the "raw performance" of the hash mechanism as conceivably possible (just storing and retrieving values; loading no additional macros and avoiding all computation), I dare to conclude the following:   1. On the whole, storing array elements as separate macros with constructed cs names is feasible. Compared to the usual runtimes of TeX documents, the best given "raw" times for storing 100000 array elements and retrieving random elements for 1000000 times are OK and are probably completely dwarfed by any way in which these 1000000 values are processed further by the TeX system in a real application.    2. Indeed, using `\number` to encode a numeric key is not optimal for array performance.   3. The solution given by Bruno Le Floch for achieving a "hash-optimised" number encoding assures a significantly better hash performance at small computational cost (see also below).   4. The total length of the cs name doesn't seem to be significant.   5. When using `\number`, inexplicably the overall performance of the array implementation is almost directly inversely proportional to the "static" prefix in front of the array access key (much less so for any other number encoding).  ## Comparison of engines The test results cited above are with the original TeX engine. I ran the test suite shown above also with other engines.   * `pdftex` gives slightly less performance overall, but really insignificant.   * `xetex` also gives slightly less performance overall, looking a little more significant (up to **1.5** times slower). With `luatex` the performance differences are a bit more subtle: cases which are fast with TeX are sometimes significantly slower (up to **2** times slower), while cases where TeX is slow are getting faster, so it seems LuaTeX is better at dealing with those cases (long static prefix) where the original engine is bad. ## Does everything get slower? One more concern about using the internal hash table to store arrays as thousands of cs names is that it will slow down **all** processing due to   1. the fact that the size of the hash table has to be extended for really huge amounts of data, so looking up _any_ cs name will take more time;   2. the fact that the generated cs names "clutter up" the hash table, leading to hash conflicts for regular macro names as well. I tested this by generating the above test suite with setting `\def\experimentsize{1000000}` and using the following test file:               \documentclass{article}          %\input{testhash1-setup}     %\input{testhash25-setup}          \usepackage{pgfplots}               \let\rmdefault\sfdefault          \begin{document}          \newcommand\test[1]     {%     [can't repeat the example code here because of post length limit]     }          \test{1}          \test{2}          \test{3}          \test{4}          \test{5}          \test{6}          \end{document}      The XKCD plot example is taken from this answer. The intention for using a TikZ example is that TikZ loads a real lot of source code, defining and using heaps of macros, so if anything is wrong with hash performance for normal macro processing, this is one application where it should get most observable. Note that the `\input` statements (commented out above) are executed `before` loading `pgfplots`, to maximise potential hash conflicts when loading TikZ. I had to extend the internal tables as follows to compile the example file with one of the `\input` statements uncommented:               export hash_extra=1500000     export max_strings=2000000     export pool_size=30000000      First, let's look at the effect of the larger hash table. If I compile the example _with both`\input` statements commented out_ with `time pdflatex` without any extension, I get the following result:               real    0m3.686s     user    0m3.628s     sys 0m0.044s      With the abovementioned extensions in place, I get               real    0m3.746s     user    0m3.684s     sys 0m0.052s      I would say this is a noticeable (also reproducible) slowdown, but totally insignificant for practical purposes. Now, the timing result with `\input{testhash1-setup}` uncommented:               real    0m19.760s     user    0m19.585s     sys 0m0.140s      and with `\input{testhash25-setup}` uncommented:               real    0m10.710s     user    0m10.585s     sys 0m0.104s      And here are the timing results for "only" processing `testhash1-setup` with the following test file:               \documentclass{article}          \input{testhash1-setup}          \begin{document}     \end{document}      (Note there will be a small overhead due to starting up LaTeX twice.)               real    0m15.401s     user    0m15.297s     sys 0m0.084s      And for `testhash25-setup`:               real    0m4.218s     user    0m4.104s     sys 0m0.104s      Summing the run times of the separate computations and comparing with the joint computation, I get   * For `testhash1-setup`, the sum of both "separate" computation times (`usr` timing) is _18.981s_ , while the joint computation takes _19.585s_.   * For `testhash25-setup`, the sum of both "separate" computation times is _7.788s_ , while the joint computation takes _10.585s_. Interestingly, this means that when the array key is encoded with `\number`, the following computation is not slowed down significantly, while when using my faster encoding method, **the slowdown is on the order of the original running time of the TikZ example**! So this example actually allows to observe the effect of hash table cluttering: As my encoding tries to spread the hash codes for array elements across the whole hash table, the number of hash conflicts for regular macro names increases and indeed **the performance is halved**. The results are comparable for the encoding by Bruno Le Floch. Note however that the experiment setting is really not very realistic, because loading the array code _before_ TikZ comes down to setting up data structures before defining the actual document macros, while usually it will be the other way round: First, macro packages and suchlike are loaded and later during document processing, data is stored in arrays which are defined on the fly. So what happens when I move the `\input{testhash25-setup}` _after_ the `\usepackage{pgfplots}`?               real    0m8.928s     user    0m8.809s     sys 0m0.100s      So the slowdown is still noticeable, but much less than when executing the other way round. Hence, my conclusions from these experiments are:   1. Extending the internal hash table alone doesn't slow TeX down.   2. Cluttering up the hash table with macros for array elements _does_ slow TeX down noticeably.   3. It makes a difference when macros are defined; the basic packages should come first and the definition of array elements should come as late as possible.   4. When deciding how to encode array indices, all effects should be taken into account. It makes no sense to trade slightly better hash performance for vastly slower overall run time. ## We haven't even talked about arrays yet... Indeed, so far all tests were at the "raw hash" level, just executing the pre- expanded store and retrieval commands. In a realistic application setting, of course the encoding of array keys has to take place at execution time. That's the purpose of the macro `\mkarrayexperiment` in the test suite above: it will generate a test file containing statements like               \numhashstore{foo}{1}{1}     \mycount \numhashretrieve{foo}{438549}\relax       storing and retrieving values to/from an array `foo` with the access macros defined above. From the given test suite, I get the following results:               starting test "testnumhasharray"; size 100000; array implementation "numhasharr     ay" (./numhasharray.tex)) )     real    0m5.472s     user    0m5.192s     sys 0m0.048s          starting test "testhashnumhasharray"; size 100000; array implementation "hashnu     mhasharray" (./hashnumhasharray.tex)) )     real    0m3.754s     user    0m3.664s     sys 0m0.032s          starting test "testcodenumhasharray"; size 100000; array implementation "codenu     mhasharray" (./codenumhasharray.tex)) )     real    0m5.114s     user    0m4.868s     sys 0m0.048s      Here, we can see that the effort for encoding the array keys diminishes the distance between using `\number` and the hash-optimized approach of Bruno Le Floch. My own encoding is disqualified because the effort for generating the array keys outweighs the added hash efficience :-( But the good new is that even taking the time needed for encoding into account, the approach of Bruno Le Floch beats the array index based on `\number`. ## Are there other approaches? I'm interested to hear whether there are other approaches to implementing an array apart from the hash-based one studied here which have comparable performance. The `l3prop` package offers an implementation of "property lists" which could be accessed like arrays. But with a test similar to the above, I got a performance which is totally incomparable to the hash-based implementation (100 times slower for 1000 array entries and 10000 retrievals; might even get worse for larger array sizes). So this doesn't seem to be an alternative for storing huge amounts of data. I tried to devise a simple macro-based solution where all entries are stored in a single macro expansion, but unfortunately I couldn't think of any way for retrieving the value of an array entry with any kind of efficiency (I thought delimited arguments could be used for that, but couldn't figure out how). But let me speculate a little: Let's talk about _n_ array entries with a total content length of _m_. Conceivably, _m>>n_. Then all solutions for storing the _n_ entries I can imagine fall into two categories:   1. New cs names on the order of _n_ are created. This is the solution sketched above, but also, for instance, all kinds of dictionary implementations where nodes of a tree are stored as single macros.   2. At least one macro whose expansion text is on the order of _m_ is created. Clearly, no solution based on the first approach will be more efficient than the simple implementation given above, because that one needs exactly **one** access to the internal hash table, and you can't go lower than that. But I think that also no solution based on the second approach can be more efficient, because however you implement it, to retrieve an array element, you'll have to expand a macro whose expansion text is on the order of _m_ , and that is clearly slower than a single access to the internal hash table, so there. But maybe I'm just lacking imagination, so feel free to present a third solution, or in fact any array implementation more efficient than the simple hash-based one. ## Final questions Based on what I know so far, my basic question can be refined as follows:   1. Looking at the actual implementation of TeXs hashing algorithm, what is the best way to construct cs names for maximum array performance?   2. Is there any fundamentally different method of implementing an array in TeX which gives comparable (or even better) performance than the hash-based one?   3. Am I somehow looking into the wrong direction? Maybe my experiment setup is somehow fundamentally flawed and I'm getting insignificant results? Should I test differently?   4. I used the original TeX engine for my tests, and am not using any construct specific to any TeX extension. I tested the very same code with other engines, not giving any unexpected or significantly different results. It is rather clear that LuaTeX offers to implement arrays in Lua, hence giving completely different options. Are the other engines (`pdftex`, XeTeX) offering anything which might aid in implementing arrays?


title: hyperref using ref: How can I avoid the section number

text: perf~\ref{soft_reset_perf}          \phantomsection     \item[perf]:~\label{soft_reset_perf} Indicates that a soft reset has been performed.      It shows next to 'perf' the section number. How can I just get a link without section number? With `~\nameref{soft_reset_perf}` I get the name of the section in which the label is defined. I want the item name ('perf' in this case) to be displayed instead of the section name.


title: Placing a triangle around nodes in a tree

text: I have a tree filled with numbers and I want to mark a subtree by drawing a triangle around it. I can't seem to get it working. My attempt:               \documentclass{article}     \usepackage{tikz}     \usetikzlibrary{shapes,fit}     \begin{document}     \begin{tikzpicture}     \node at (0,0) {3};          \node (7) at (-1/2,-1) {7};     \node at (1/2,-1) {4};          \node at (-1,-2) {2};     \node at (0,-2) {4};     \node at (1,-2) {6};          \node (8) at (-3/2,-3) {8};     \node at (-1/2,-3) {5};     \node (9) at (1/2,-3) {9};     \node at (3/2,-3) {3};          \node[isosceles triangle,fit = (7) (8) (9)] {};     \end{tikzpicture}     \end{document}


title: Word count without footnotes

text: Do you know how can I count the words without footnotes? I saw that there was a general solution for counting words without specific environments but that seems very cumbersome. I was wondering if there wasn't anything easier. I have used the statistics tab to see the word count and it includes all my footnotes; however, many journals in my field have a word limit for the body of the text and then a separate word limit for footnotes). Thanks


title: How to add text into a QR-Code?

text: I want to add a text to the QR-Code. I want a small numbers in one of the four black squares.               \documentclass[a4paper, 12pt, parskip]{scrartcl}          \usepackage[utf8]{inputenc}     \usepackage{pst-barcode}     \usepackage{auto-pst-pdf}          \begin{document}       \section{Demo}       \begin{pspicture}(1.378in, 1.5in)         \psbarcode[]{1}{height=1.378 width=1.378}{qrcode}         {\color{white}1}       \end{pspicture}       \begin{pspicture}(1.378in, 1.5in)         \psbarcode[]{2}{height=1.378 width=1.378}{qrcode}         {\color{white}2}       \end{pspicture}     \end{document}      I tried `textpos` with no success. Has somebody other ideas?


title: How to get simple margins of 2cm?

text: I have been trying for several days to get simple margins like a Word Document. I have started to learn latex 1 month ago, so Im not very familiar with its strange margins !! Anyways, I would like to get a simple page with 2cm of margins.                   \documentclass{memoir}         \usepackage{color,calc,graphicx,soul,fourier}         \usepackage{lipsum}                  \definecolor{nicered}{rgb}{.647,.129,.149}             \makeatletter             \newlength\dlf@normtxtw             \setlength\dlf@normtxtw{\textwidth}             \def\myhelvetfont{\def\sfdefault{mdput}}             \newsavebox{\feline@chapter}             \newcommand\feline@chapter@marker[1][4cm]{%               \sbox\feline@chapter{%                 \resizebox{!}{#1}{\fboxsep=1pt%                   \colorbox{nicered}{\color{white}\bfseries\sffamily\thechapter}%                 }}%               \rotatebox{90}{%                 \resizebox{%                   \heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}%                 {!}{\scshape\so\@chapapp}}\quad%               \raisebox{\depthof{\usebox{\feline@chapter}}}{\usebox{\feline@chapter}}%             }             \newcommand\feline@chm[1][4cm]{%               \sbox\feline@chapter{\feline@chapter@marker[#1]}%               \makebox[0pt][l]{% aka \rlap                 \makebox[1cm][r]{\usebox\feline@chapter}%               }}             \makechapterstyle{daleif1}{               \renewcommand\chapnamefont{\normalfont\Large\scshape\raggedleft\so}               \renewcommand\chaptitlefont{\normalfont\huge\bfseries\scshape\color{nicered}}               \renewcommand\chapternamenum{}               \renewcommand\printchaptername{}               \renewcommand\printchapternum{\feline@chm[2.5cm]\par}               \renewcommand\afterchapternum{\par\vskip\midchapskip}               \renewcommand\printchaptertitle[1]{\chaptitlefont\raggedleft ##1\par}             }             \makeatother             \chapterstyle{daleif1}         \usepackage[showframe]{geometry}                   \geometry{         a4paper,         right=2cm,         left=2cm,         nomarginpar,         top=2cm,         bottom=20mm         }         \begin{document}              \chapter{Test chapter}         \lipsum[2]         \end{document     }      ![enter image description here](http://i.stack.imgur.com/MhvNz.png) However, I don't have a right-margin and left-margin of 2 cm when I print my file. It makes me so furious ! I don't understand why it doesn't work. The rightmargin is longer than the left-margin, so I guess there is still a kind of margin on the right. Yet, I have already removed the marginpar... Does anyone can help me ? Thanks. Edit : I got : rightmargin = 1.8cm, leftmargin = 2.2cm, textwidth = 17cm


title: Overlap of colored rows

text: I have the following code               \documentclass{scrartcl}          \usepackage[table]{xcolor}     \usepackage{tabu}          \begin{document}%          \tabulinesep=_1em^1em     \everyrow{\tabucline[1pt]{-}}          \begin{tabu}{@{}XX[3,L]}         \tabucline[1.5pt]{-}            blabla &            blabla        \tabularnewline        \taburowcolors 1{green!30 .. green!30}           \multicolumn{2}{@{}c}{\textit Pause}         \tabularnewline        \taburowcolors 1{white .. white}           blabla &           blabla        \tabularnewline         \taburowcolors 1{green!30 .. green!30}           \multicolumn{2}{@{}c}{\textit Pause}         \tabularnewline        \taburowcolors 1{white .. white}           blabla &           blabla        \tabularnewline \tabucline[1.5pt]-     \end{tabu}           \end{document}      wich results in ![enter image description here](http://i.stack.imgur.com/yJgdk.png) Unfortunately there is an overlap in the colored rows. How is it possible to align the colored rows with the beginning of the horizontal lines?


title: How to change footnote to symbol in table in minipage without special package?

text: Based on How to change symbol for footnote in minipage and Symbols instead of numbers as footnote markers I expected this code to work:               \documentclass{article}            \begin{document}           \begin{minipage}{1\textwidth}                  \renewcommand*{\thempfootnote}{\fnsymbol{footnote}}            \begin{tabular}{ll}            \hline             foo & bar\footnote[1]{buzz} \\             foobar & barfoo \\             \hline            \end{tabular}                \end{minipage}       \end{document}      However, I don't get any footnote symbol at all. ![enter image description here](http://i.stack.imgur.com/3RXOG.png) It feels like I have made some silly mistake but I can't figure it out. What have I missed?


title: KOMA script: How to reduce vertical space below caption

text: The vertical space below figure caption is large how to reduce it.               \documentclass[a5paper]{scrbook}          \usepackage[demo]{graphicx}               \begin{document}          \chapter{Sample chapter}          \section{Sample section}          %     %     Some text more text more text more text more text more text more text more text more text more text more text.          \begin{figure}[htb!]     \centering     \includegraphics[width=0.25\textwidth]{frog.jpg}     \caption{A test caption without label for a figure}     \end{figure}          %     Some text more text more text more text more text more text more text more text more text more text more text.               \end{document}      ![enter image description here](http://i.stack.imgur.com/ecZPz.jpg) > Q: Why i get typearea warning? what does it mean?


title: Problem with Texlipse and auto-ps-pdf

text: I'm using the Eclipse-plugin Texlipse as my preferred LaTeX-editor. But since I'm using auto-pst-pdf for PStricks graphics in pdf-files Texlipse doesn't manage the complete compilation. That works just to the point where the wrapped pstricks-code has been compiled in a .ps-file (-autoop.ps). The remaining process with ps2pdf, pdfcrop etc. is failing. Of course, pdflatex will be executed with --shell-escape. That's suspicious, when I'm running the same tex-file with the latex+dvips+ps2pdf procedure everything works fine, although ps2pdf has been used as well. Furthermore, when I execute that tex-file with Texmaker or Texworks the pdflatex-procedure works without any failures, same when i execute this file with the terminal manually. Just the pdflatex-procedure with Texlipse fails. I don't know why. Texlipse uses the same pdflatex-program in the same path as Texmaker/works or manually. Isn't it? That would be nice, when you can help me


title: How to edit the linear programming in LaTeX?

text: How to edit a linear programming as the following:               Max  z = x1 + 12x2     s.t.  3x1 + x2 + 12x3 ≤ 5            x1      +   x3 ≤ 16          15x1 + x2        = 14          xj ≥ 0, j=1,2,3.      I want the format to be strictly like the example. Thanks for all the answers below. What I need is just like the picture as following ![enter image description here](http://i.stack.imgur.com/QFjdI.png)


title: Are LaTeX et al. languages or packages?

text: Are LaTeX and friends considered programming languages or packages? I'm applying to a job and would like my employer to know of my LaTeX proficiency. There's already a list of programming languages (Python, C++, Matlab, ...) and a list of "packages" (Office, COMSOL, Matlab, ...) on my CV. In which list does LaTeX fit? Or should it be under another heading?


title: LaTeX tables: How do I make bold horizontal lines (typically \hline)?

text: The title says it all: In LaTeX tables: How do I make bold horizontal lines (typically `\hline`)?


title: \sqrtsign and \sqrt

text: The following lines caught my attention while browsing `source2e` while looking for the definition of another command.               \DeclareMathRadical{\sqrtsign}{symbols}{"70}{largesymbols}{"70}      and               \DeclareRobustCommand\sqrt{\@ifnextchar[\@sqrt\sqrtsign}     \def\@sqrt[#1]{\root #1\of}      What was `\sqrtsign` for? I tried `\sqrtsign{x}` and it outputs something similar to `\sqrt{x}`.


title: Fanciest way to include Mathematica code in LaTeX

text: I am trying to include a Mathematica code in LaTeX. To obtain the Mathematica code I just exported notebook as PDF. I didn't like the way it was included in my TEX code so I just thought of adding a box around picture so as to make it a bit more fancy. It's not yet there but it's better than nothing. The code used is               \documentclass[a4paper,11pt]{article}     \usepackage{kerkis}     \usepackage{amsmath}     \usepackage{amssymb}     \usepackage{amsfonts}     \usepackage{amsthm}     \usepackage[pdftex]{graphicx}     \usepackage{xcolor}          \begin{document}     \begin{align}     \nonumber W_{r\rightarrow\infty}=&-\int_{r}^{\infty}\!F\,\mathrm{d}y=-    \int_r^\infty \!     \dfrac{1}{4\pi \epsilon_0} \dfrac{q^2}{\alpha^2}     \dfrac{\alpha^3}{y^3}\left(1-    \dfrac{\alpha^2}    {y^2}\right)^{-2}\,\mathrm{d}y\\     =&-\dfrac{1}{4\pi \epsilon_0} \dfrac{q^2}{\alpha^2}\alpha^3     \underbrace{\int_r^\infty     \! y^{-3} \left(1-\dfrac{\alpha^2}    {y^2}\right)^{-2} \,\mathrm{d}y}_{I} \label{eq:WcondI}     \end{align}          \setlength{\unitlength}{1cm}     \begin{picture}(15,5)     \color{blue}     \put(-1,0){\line(0,1){5}}     \put(0,1.5){\includegraphics[scale=0.8]{math}}     \put(-1,0){\line(1,0){15}}     \put(14,0){\line(0,1){5}}     \put(-1,5){\line(1,0){15}}     \end{picture}          \end{document}      My output is ![](http://i.imgur.com/88L93.png) Any ideas on how to include Mathematica code in a more aesthetically way? **Edit** :At first I used package `listing` but the problem was the fraction and the fact that I don't know how to include in a convenient way `In[1]` and `Out[1]`


title: Customized 'list of...'

text: I am using the covington package to manage my examples. I would now like to create my list of examples, right after my list of figures and tables. Is there any way to do it? example of an example:               \begin{examples}     \item blabla     \end{examples}


title: Small text in table does not recalculate line spacing

text: I'm using `tabu` to create a table that has a couple multi-line cells (the `m` style). However, when I set the line spacing outside the table, it seems that the space between lines is not recalculated in the table, and when I make the font small, the spacing is too large: ![](http://i.stack.imgur.com/q1MVy.png)               \documentclass{article}     \usepackage{tabu}           \begin{document}          \linespread{1.5}\selectfont          \noindent     \begin{tabu}{|X[m,c]|X[-2,m,c]|X[m,c]|}         {\scriptsize Line 1 \linebreak too much space here} &         {\Huge Title} &         Right side \linebreak Line 1 \linebreak and line 2     \end{tabu}          A normal paragraph: 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.          \end{document}      Putting another `\linespread` inside the table doesn't change anything. How can I solve this?


title: How to adjust font size or kerning to fit line width?

text: I have some text that nearly fits the given line width. I can see that a minimal adjustment of font size or kerning would make the text fit, but how do I tell LaTeX to squeeze the text? Yes, this would be bad typography for an average paragraph, but in my case it is a custom In a custom quotation environment, that has a smaller font size anyway, so it won't look ugly.


title: How to change TeXLive installer temp?

text: I want to install TeXLive on NAS; the problem is that its built-in Linux has very small /tmp partition which is quickly filled by packages downloaded by installer. Yet I have a plenty of place on other partitions, so it would be nice to somehow change temp location it uses... Any ideas?


title: Parametrized inclusion of sub-files

text: I'm preparing a Resume using LaTeX, mainly for the purpose of easy customization. In particular, I wish to be able to generate different outputs from the same input file by changing a few parameters. One such requirement is: specific chunks of text have to be chosen according to one of the input parameters ("dev"/"training"/"generic"). I can have the chunks of text appropriate to each parameter in a separate .tex file ("dev_summary.tex", "training_summary.tex", etc.) and `\input` them according to the parameter. I've currently implemented this with:                 \newcommand{\whoami}[1]{trainer#1}      and later                \input{\whoami{_summary.tex}}      Now I just have to change the string "trainer" in the newcommand line whenever I want to change the first parameter. However, is there a better way where I can keep this file unedited and instead pass this change as a commandline argument?


title: biblatex-chicago TeXworks Bibdesk

text: I'm using TeXworks to compile a paper, but can't figure out how to include a bibliography page with the author-date format style. I want to refer to papers in the format (Author, YYYY) and in the bibliography to have author, then year. I was previously using `\bibliographystyle{ieeetr}` and my document was compiling just fine. Now, I've downloaded a bunch of packages following David Fussner's instructions for the `biblatex-chicago` package, but for the life of me I can't make my document run. I have a bunch of other packages in the preamble that may be conflicting with `biblatex-chicago` (I've added them as I've needed to do things with figures, tables, footnotes at the end of the document, etc). Here's my preamble:               \documentclass[12pt]{article}     %     \usepackage{amssymb}     \usepackage{amsfonts}     \usepackage{amsmath}     \usepackage[nohead]{geometry}     \usepackage[singlespacing]{setspace}     \usepackage[bottom]{footmisc}     \usepackage{indentfirst}     \usepackage{endnotes}     \usepackage{graphicx, subfigure}     \usepackage{rotating}     \usepackage{booktabs}     \usepackage[tableposition=top]{caption}     \usepackage{placeins}     \usepackage{afterpage}     \usepackage{multirow}     \usepackage{hyperref}     \usepackage{color, colortbl}     \definecolor{Gray}{gray}{0.9}     \usepackage[justification=centering]{caption}     \usepackage{array,longtable,calc}     \usepackage{arydshln}     %     \newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}     %     \usepackage[margin=65pt,font=small,labelfont=bf,justification=raggedright,singlelinecheck=false]{caption}     \DeclareGraphicsExtensions{.eps,.jpg}     \usepackage{etoolbox}     \usepackage[authordate,backend=biber]{biblatex-chicago}     \bibliography{newreferences.bib}      I'm citing using `\cite{Glomm1994}`and at the end I have:               \newpage     \printbibliography      I'm getting all sorts of errors. Once it actually ran, but with no bibliography page. I need some logic to follow when adding the packages necessary for `Chicago` style bibliography. There are so many options out there I no longer know what I'm doing. Any help would be appreciated. I have a deadline and I've dedicated too much time on something that should be simple.


title: Lyx on Mac inputs diacritical marks instead of punctuation marks

text: I've just installed Lyx 2.0.7.1 on Mac OS X (Mavericks) and when trying to type in Lyx, some keys behave irregularly. More specifically, typing some punctuation marks on my keyboard (such as period, colon, question mark and semicolon) does not result in those characters being inputed. Instead, diacritical marks (accent marks such as á) are inputed instead. This problem only occurs when I'm NOT in formula mode. My Lyx keyboard map is american (I've also tried american-2) and my keyboard layout in Mac OS X is U.S. (I've also tried U.S. PC). I also have hebrew on both my mac and Lyx but the problem happens when I'm in English on both. EDIT: update. I've realised now that pressing the keyboard key twice actually produces the desired key. For example pressing period twice types period whereas pressing period and then a produces ȧ. Similarly, pressing SHIFT+semicolon/colon key and then semicolon/colon again produces colon etc. Still no explanation though as to why this is happening. Can't find any mention of it online


title: How to prevent pagebreak for a custom environment?

text: I use the following custom environment _emailHeader_ and macros to format an email header  (credits belong to egreg).               \definecolor{emailHeaderBackground}{RGB}{225,225,225}     \usepackage[framemethod=tikz]{mdframed}     \newmdenv[       skipabove=0em,       skipbelow=1em,       hidealllines=true,       backgroundcolor=emailHeaderBackground,       roundcorner=3pt]       {emailHeader}      In the document ...               \begin{emailHeader}       \emailFrom[John Doe]{john.doe@stackexchange.com}       \emailSubject{Re: Please do break apart}       \emailDate{Wed, 22 Aug 2012 12:23:18 +0200}       \emailTo[Jane Doe]{jone.doe@stackexchange.com}       \begin{emailsCc}         \email[Barack Obama]{barack.obama@whitehouse.gov}         \email[Michelle Robinson]{michelle.robinson@whitehouse.gov}       \end{emailsCc}     \end{emailHeader}      The output looks like this ... ![E-Mail header](http://i.stack.imgur.com/fr0c8.png) I use the environment several hundred times in the document. Sometimes it happens that the email header is at the end or beginning of a page. Then, it breaks into separate lines. As you can see the environment is not a _verbatim_ environment for which I found settings to avoid the page break. **Question:** How can I prevent a pagebreak for the above environment?   I want the command to be added to the environment definition. I do not want to edit all the places where I use the set of commands.


title: Manually add legend symbols in text (without \label and \ref)

text: I would like to add legend symbols from `pgfplots` in my text. I am aware of the possibility to use the `\label` and `\ref` commands but my setup is complicated and I fear that making it work will more time consuming than setting the small drawings manually. I use externalization, my plots are generated with an intricate `\pgfplotsinvokeforeach` inside a template that is used several times in the document… What I am looking for is a command like               \legendimageintext{mark=x, draw=blue}      that would draw a small blue dash with a cross on it, just as the legend post of a plot with similar styles would appear. _Note: if you want to put the legend in caption or in text, it is usually simpler to use \ref and \label as described in the pgfplots manual orthere. My question related to special cases where the canonical approach is not usable._


title: line spacing among paragraphs and displaymath issue

text: Currently, I am writing an academic paper in latex and facing some issues. It might be due my lack of expertise in Latex or ignorance of some tricks or tweaks. Currently there are two issues i am facing.   1. no space among words I have written the following line of code               \begin{displaymath}        TPR = \frac{\# lines selected from GSL in C}{\# lines in GSL in C}     \end{displaymath}      and it appears like this ![enter image description here](http://i.stack.imgur.com/VMdyV.jpg)   1. line spacing among paragraphs Other issue i am facing is about line spacing. I have pressed an enter key at the end of each paragraph to start a new one. Also, i have tried the \ and \par commands to tackle this issue but it remains the same. What I am looking for is start of paragraph like this ![enter image description here](http://i.stack.imgur.com/5L1W6.jpg) but it appears like this ![enter image description here](http://i.stack.imgur.com/NOFyl.jpg) Any solution for both issues By default i have used a blank like between each paragraph. Here is an example - screenshot from my Texmaker. ![enter image description here](http://i.stack.imgur.com/DFiwV.jpg)


title: No numberings, no numbers (section, chapter, subsection etc.) in header?

text: I am using `scrpage2` with `scrbook.` I would like to have no numbers or numbering of sections, chapters, etc.. in the header. How can I achieve that? I have the following example:               \documentclass[12pt, draft]{scrbook}     \usepackage[automark]{scrpage2}        \renewcommand*{\headfont}{%      \normalfont\scshape}           \begin{document}     \pagestyle{scrheadings}          %Formatting     \ohead{\pagemark}      \cehead{\leftmark}     \cohead{\leftmark}     \ofoot[]{}           \chapter{Intro}     \automark[chapter]{chapter}           \chapter{Chapter 1}     \cehead{\leftmark}      \cohead{\rightmark}      \automark[subsection]{chapter}          \chapter{Chapter 2}     \automark[section]{chapter}          \chapter{Final Chapter}     \cehead{\leftmark}      \cohead{\leftmark}           \end{document}


title: mathds font not working:(

text: I am using TeX Live (Win 7). My code is the following:               \documentclass[11pt]{article}     \usepackage{amsmath,amssymb,amsthm,mathrsfs,amsfonts,dsfont}           \begin{document}     $\mathds{N}$     \end{document}      But it doesn't produce the desired mathds font. This problem has been bothering me for a long time. Anyone can help me out? Thank you! After I added `\listfiles` in the preamble as asked by @Harish Kumar, below is what I got:               *File List*           article.cls    2007/10/19 v1.4h Standard LaTeX document class            size11.clo    2007/10/19 v1.4h Standard LaTeX file (size option)           amsmath.sty    2013/01/14 v2.14 AMS math features           amstext.sty    2000/06/29 v2.01            amsgen.sty    1999/11/30 v2.0            amsbsy.sty    1999/11/29 v1.2d            amsopn.sty    1999/12/14 v2.01 operator names           amssymb.sty    2013/01/14 v3.01 AMS font symbols          amsfonts.sty    2013/01/14 v3.01 Basic AMSFonts support            amsthm.sty    2004/08/06 v2.20          mathrsfs.sty    1996/01/01 Math RSFS package v1.0 (jk)            dsfont.sty    1995/08/01 v0.1 Double stroke roman fonts              umsa.fd    2013/01/14 v3.01 AMS symbols A              umsb.fd    2013/01/14 v3.01 AMS symbols B             ursfs.fd    1998/03/24 rsfs font definition file (jk)           ***********      The log file can be found here: https://dl.dropboxusercontent.com/u/29066158/font.log ![enter image description here](http://i.stack.imgur.com/ndEKM.png)


title: Custom environment problems using environ

text: As shown by my MWE, I have two small issues that I'd like to get assistance with in fixing. First off: When I start two `problem` environments one after another without a blank space between the `\end{problem}` and `\begin{problem}`, my second problem goes in the right margin instead of beneath the previous one. Secondly, I'd like it, if possible, to not have a blank space (as shown in the 4th problem) if I choose to omit a problem description. I'd like to do as in problem 5, but as it is now, the first letter shows up incorrectly as the problem title.               \documentclass{article}          \usepackage{environ}     \usepackage{array}          \newcounter{problem}     \setcounter{problem}{0}     \newlength{\mylen}     \settowidth{\mylen}{100}          \NewEnviron{problem}[1]{%       \stepcounter{problem}\noindent       \begin{tabular}{m{\mylen}p{\dimexpr\linewidth-\mylen-3\tabcolsep\relax}@{}}         \arabic{problem}. & \textbf{#1}\\[1mm]         & \BODY       \end{tabular}}%          \begin{document}       \begin{problem}{foobar}         test           \end{problem}       \begin{problem}         test       \end{problem}          \bigskip\bigskip\bigskip            \begin{problem}{foobar}         test           \end{problem}            \begin{problem}{}         test2       \end{problem}            \begin{problem}         test       \end{problem}     \end{document}


title: XeLaTeX can find font, but xdvipdfmx can't

text: I had hoped to use the Minion and Myriad fonts from my new copy of Adobe CS 5 in XeLaTeX; but `\setmainfont{Minion Pro}` produces the following error: (output of `xdvipdfmx -vvv` shown) > DVI File Info   >  Unit: 25400000 / 473628672   >  Magnification: 1000   >  Media Height: 41484288   >  Media Width: 26673152   >  Stack Depth: 3   >  Page count: 1   >  DVI Comment: XeTeX output 2010.08.20:1057   >  DVI file font info   >  TeX Font: MinionPro-Regular loaded at ID= 16, size= 9.96pt (scaled 100.0%)   >  tufte.xdv -> tufte.pdf   >  D:/TEMP/dvipdfmx.a0056400001 [1 ** ERROR ** Cannot proceed without the > "native" font: MinionPro-Regular (Minion Pro Regular)...   >  Output file removed. Variations of the argument, such as `MinionPro`, `MinionPro-Regular`, `Minion Pro Regular`, etc., also produce the error. Refreshing the font cache, with `fc-cache -fv`, doesn't change anything either. I have determined that it is the output driver, xdvipdfmx, that is causing this error, since invoking xelatex with `\--no-pdf` works without any problems. Apparently XeLaTeX can find the font, but the output driver can't. To make things even more bizarre, if I select the font like this:               \setmainfont[ExternalLocation,%      BoldFont=MinionPro-Bold.otf,%      ItalicFont=MinionPro-It.otf,%      BoldItalicFont=MinionPro-BoldIt.otf]{MinionPro-Regular.otf}      everything works as expected. Can somebody advise me as to what is going on here? **UPDATE** : I changed above to show the output of `xdvipdfmx -vvv`.


title: Boxed pgfplots reference in the text

text: I want to make a reference to a pgfplots graph in the text. The reference should be surrounded by a small box. I have tried several things but it always looks ugly. How can I vertically align the legend image in the box? How can I align the box to the baseline.               \documentclass{minimal}     \usepackage{pgfplots}     \begin{document}     \begin{tikzpicture}       \begin{axis}         \addplot[color=red] coordinates {(1, 1) (2, 200)};         \label{pgfplots:plot}       \end{axis}     \end{tikzpicture}\\     Some text \fbox{\ref{pgfplots:plot}} some text\\[1cm]     Some text \protect\tikz[baseline={([yshift=-.8ex]current bounding box.center)}] \protect\node[rectangle, color=black, align=center, draw] (P) at (0,0) [draw] {\ref{pgfplots:plot}}; some text     \end{document}


title: Why are my post script commands not getting passed the LaTeX compiler?

text: The following MWE               \documentclass{article}     \usepackage{pstricks}     \begin{document}          \begin{pspicture}       \rput{!240 6 div}(0,0){Hello World}     \end{pspicture}          \end{document}      is not able to parse the post script command. Why?


title: Command analogous to \afterpage, but for lines instead of pages

text: Sometimes I would like to tell latex to do something after it finishes the line currently being typeset. For example, one might want to use the command `\needspace{4\baselineskip}` (assuming the `needspace` package is loaded) in the middle of a paragraph to prevent a pagebreak after the current paragraph. If done naively, this could end the current paragraph prematurely. I know that some standard latex commands like `\vspace` automatically wait until the end of the current line before executing. Is there a way to mimic this behavior for other commands? Note: Personally, I don't think a MWE is really helpful in this case. However, since I am sure someone will ask for one if I don't provide one, here is a not-entirely-minimal working example:               \documentclass[letterpaper]{article}     \usepackage{lipsum}     \usepackage{needspace}          \usepackage{amsthm}     \theoremstyle{plain}     \newtheorem{exercise}{Exercise}          \usepackage{xcolor}     \newcommand{\blank}[1]{\textcolor{white}{#1}}     %\newcommand{\blank}[1]{#1}          \begin{document}     \lipsum[1-4]     \begin{exercise}     This is an exercise that involves an equation, which is printed below.     \begin{equation}     1+1=2     \end{equation}     Please study the equation and somehow do something in the Solution box,     which may or may not be filled in depending on which line is commented out.     Please study the equation and\needspace{4\baselineskip}\noindent somehow do something in the Solution box,     which may or may not be filled in depending on which line is commented out.     \end{exercise}     \begin{proof}[Solution]     \blank{%     \lipsum[5-6]\qedhere%     }     \end{proof}     \end{document}


title: Best way to draw scaled polygons in tikz

text: I want to draw pictures like this ![Originally from wikipedia](http://i.stack.imgur.com/4hCSs.png) or this one ![Originally from wikipedia](http://i.stack.imgur.com/GWHjU.png). It is clear how to do this "manually" with TikZ. However is there a way to do it automatically. I.e. I just want to define the polygon (for example the yellow triangles in the pictures above), a center point Z and a scaling factor m and then get the corresponding picture (as in my examples) automatically generated by that input data.


title: How can I hyperlink figures and tables in LaTeX?

text: I can hyperlink references by `hyperref` package. But I can not hyperlink figures and tables? should I use any certain package for labeling ?


title: Getting MikTex on Windows 8 to run

text: I downloaded MiKtex 2.9 for windows 8 64 bit, but I can't find out how to run that software as there is no shortcut on desktop or on the APP page. If any one has used Miktex on windows 8 OS then please help me on the issue.


title: How can I add chapter support to and find information about the paper class?

text: I typed `paper` instead of `report` by accident as the argument of `\documentclass`... and discovered that `paper` is very, very nice. However, it doesn't seems to support chapters. How can I add chapter support to it or adapt report/books to looks like documents using the `paper` class? Further, where I can find more information about `paper`? Googling "paper latex" didn't return anything relevant or useful...


title: Vertical Centering in a multicols

text: In a document I have several `multicols` units, in which on one side there is an image and on the other side some information in a `itemize`. Now, depending on the image / information, the two "sections" vary in their vertical size. Is there a possibility to center both parts inside that `multicols` unit? For example I have               \begin{multicols}{2}        \begin{figure}[H]             \includegraphics[scale=0.7]{1bitalu.png}         \end{figure}              \vfill         \columnbreak              \begin{itemize}             \item "Arithmetic Logical Unit" für mehrere Rechenarten             \item Addition, Subtraktion, logisches AND / OR, Vergleich etc.             \item Parallele "Berechnung" aller Operationen             \item Selektion mit einem "Multiplexer"             \item Selektion durch die Kontrolleinheit (Control Unit)         \end{itemize}     \end{multicols}      which results in ![enter image description here](http://i.stack.imgur.com/5QRtr.png) but I want to have it like this ![enter image description here](http://i.stack.imgur.com/zSvUK.png) Is there an easy way to achieve this?


title: Change color of links created with \in, \at, etc

text: By default the link color of references created with `\in` or `\at` is red. How can this color be globally changed, so that all links have the same color (e.g. blue)?               \setupinteraction         [state=start,          color=blue,          style=,  % make font non-bold          ]          \starttext          \placefigure[here][fig:foo]{A figure}{         \externalfigure[testfigure]     }          Red color: \in{Figure}[fig:foo] \at{page}[fig:foo].  % How to make this blue, too?          Blue color: \goto{Link}[url(http://tex.stackexchange.com/)]          \stoptext


title: line spacing in tikzposter

text: The line spacing in blocks of the tikzposter seem to depend on the number of paragraphs or the presence of images included by the use `\includegraphics`. For example in the poster example distributed with the tikzposter package, the line spacing is different in two paragraphs of the right block titled "Columns". How could I define a uniform line spacing in all the poster blocks including the title?


title: Anchors/coordinates inside a node's text

text: # The plot Using tikz, I have a main node containing several (three) lines of text, and three "legend" nodes that point to them. If I use a `rectangle` node, then I can't access the positions of the individual lines, so I can only attach my legends to the main node itself, and can't vertically align them with their respective line: ![A rectangle node containing three lines with a unique legend for the whole node.](http://i.stack.imgur.com/iRTCh.png) If I use a `matrix` node, with each line in an individual cell, then the inter-line spacing is wrong. I could add `row sep=42pt`, but I don't know which value to put in place of 42: ![A matrix node with a cell for each line, and a legend for each line, the lines are stuck together without any vertical spacing.](http://i.stack.imgur.com/oPey7.png) As a last ressort, I added an invisible rule with a height of `\baselineskip` to each line (cell) except the first one, which seems to give a result identical to the rectangular node, except I can access the position of individual lines: ![A matrix node with a cell for each line, and a legend for each line, the vertical spacing is the same as in the rectangle node.](http://i.stack.imgur.com/HPIov.png) However, this won't work well if the line contains equations or anything that makes it higher than a regular line. This TeX.sx answer shows that the inter- line space in that case is given by `\lineskip` and `\lineskiplimit`, but I woul really fancy the idea of re-implementing that using tikz -- I wouldn't even know where to start I must admit. # The question Is there any simpler/more robust way to access each individual line in a tikz `node` as if the line was a rectangle node? # The code ## Preamble               \documentclass{article}     \usepackage{tikz}     \usetikzlibrary{positioning, matrix}     \def\legendlines#1#2{       \draw (#1) -- (#2);       \draw (#2.north west) -- (#2.south west);     }     \begin{document}     \tikzset{       mynode/.style={draw,fill=blue!30,align=center},       mylegend/.style={align=left, font=\scriptsize, inner sep=1pt}     }      ## Rectangle node               % I can't access the position of each line using a rectangle node     \begin{tikzpicture}       \node[mynode] (N123) {Node line one\\Node line two\\Node line three};       \node[mylegend, xshift=1cm, at=(N123.east), anchor=west] (L123) {Legend 1\\Legend 2\\Legend 3};       \legendlines{N123}{L123}     \end{tikzpicture}      ## Matrix node               % Using a matrix, the inter-line space is wrong. I can add row sep=42pt, but I don't know what is the correct value.     \begin{tikzpicture}       \node[mynode, matrix, matrix of nodes, nodes={inner sep=0pt}] (N123) {Node line one\\Node line two\\Node line three\\};       % Coordinates along the east side of N123       \coordinate (N1east) at (N123-1-1.east -| N123.east);       \coordinate (N2east) at (N123-2-1.east -| N123.east);       \coordinate (N3east) at (N123-3-1.east -| N123.east);       % Legend texts       \node[mylegend, right=1.0cm of N1east] (L1) {Legend 1};       \node[mylegend, right=1.2cm of N2east] (L2) {Legend 2};       \node[mylegend, right=1.4cm of N3east] (L3) {Legend 3};       % Legend lines       \legendlines{N1east}{L1}       \legendlines{N2east}{L2}       \legendlines{N3east}{L3}     \end{tikzpicture}      ## Invisible rule               % Using an invisible rule     \begin{tikzpicture}       \node[mynode, matrix, matrix of nodes, nodes={inner sep=0pt}] (N123) {Node line one\\\rule{0cm}{\baselineskip}Node line two\\\rule{0cm}{\baselineskip}Node line three\\};       % Coordinates along the east side of N123       \coordinate (N1east) at (N123-1-1.east -| N123.east);       \coordinate (N2east) at (N123-2-1.east -| N123.east);       \coordinate (N3east) at (N123-3-1.east -| N123.east);       % Legend texts       \node[mylegend, right=1.0cm of N1east] (L1) {Legend 1};       \node[mylegend, right=1.2cm of N2east] (L2) {Legend 2};       \node[mylegend, right=1.4cm of N3east] (L3) {Legend 3};       % Legend lines       \legendlines{N1east}{L1}       \legendlines{N2east}{L2}       \legendlines{N3east}{L3}     \end{tikzpicture}      ## Epilogue               \end{document}      ## Whole code               \documentclass{article}     \usepackage{tikz}     \usetikzlibrary{positioning, matrix}     \def\legendlines#1#2{       \draw (#1) -- (#2);       \draw (#2.north west) -- (#2.south west);     }     \begin{document}     \tikzset{       mynode/.style={draw,fill=blue!30,align=center},       mylegend/.style={align=left, font=\scriptsize, inner sep=1pt}     }          % I can't access the position of each line using a rectangle node     \begin{tikzpicture}       \node[mynode] (N123) {Node line one\\Node line two\\Node line three};       \node[mylegend, xshift=1cm, at=(N123.east), anchor=west] (L123) {Legend 1\\Legend 2\\Legend 3};       \legendlines{N123}{L123}     \end{tikzpicture}          % Using a matrix, the inter-line space is wrong. I can add row sep=42pt, but I don't know what is the correct value.     \begin{tikzpicture}       \node[mynode, matrix, matrix of nodes, nodes={inner sep=0pt}] (N123) {Node line one\\Node line two\\Node line three\\};       % Coordinates along the east side of N123       \coordinate (N1east) at (N123-1-1.east -| N123.east);       \coordinate (N2east) at (N123-2-1.east -| N123.east);       \coordinate (N3east) at (N123-3-1.east -| N123.east);       % Legend texts       \node[mylegend, right=1.0cm of N1east] (L1) {Legend 1};       \node[mylegend, right=1.2cm of N2east] (L2) {Legend 2};       \node[mylegend, right=1.4cm of N3east] (L3) {Legend 3};       % Legend lines       \legendlines{N1east}{L1}       \legendlines{N2east}{L2}       \legendlines{N3east}{L3}     \end{tikzpicture}          % Using an invisible rule     \begin{tikzpicture}       \node[mynode, matrix, matrix of nodes, nodes={inner sep=0pt}] (N123) {Node line one\\\rule{0cm}{\baselineskip}Node line two\\\rule{0cm}{\baselineskip}Node line three\\};       % Coordinates along the east side of N123       \coordinate (N1east) at (N123-1-1.east -| N123.east);       \coordinate (N2east) at (N123-2-1.east -| N123.east);       \coordinate (N3east) at (N123-3-1.east -| N123.east);       % Legend texts       \node[mylegend, right=1.0cm of N1east] (L1) {Legend 1};       \node[mylegend, right=1.2cm of N2east] (L2) {Legend 2};       \node[mylegend, right=1.4cm of N3east] (L3) {Legend 3};       % Legend lines       \legendlines{N1east}{L1}       \legendlines{N2east}{L2}       \legendlines{N3east}{L3}     \end{tikzpicture}     \end{document}


title: Bottom table alignment for rotated column headers

text: I've been struggling to appropriately align rotated text using `longtable`, `array` and `rotating` packages. I basically want column headers to be aligned at the bottom, however, LaTeX centres them even after issuing an explicit ragged directives.               \documentclass[a4paper,10pt]{report}          \usepackage{longtable}     \usepackage{multirow}     \usepackage{array}     \usepackage{rotating}          \begin{document}          \begin{longtable}{     >{\centering\arraybackslash}m{0.010\linewidth}|     >{\arraybackslash}m{0.60\linewidth}|     >{\arraybackslash}m{0.010\linewidth}|     >{\arraybackslash}m{0.010\linewidth}|     >{\arraybackslash}m{0.010\linewidth}|     >{\arraybackslash}m{0.010\linewidth}|     >{\arraybackslash}m{0.010\linewidth}|     >{\arraybackslash}m{0.010\linewidth}|     >{\arraybackslash}m{0.010\linewidth}}          \caption{Minimal Example Table}     \label{tab:minimal-example:the-table} \\      \cline{3-9}      \multicolumn{1}{c}{} &      \multicolumn{1}{c|}{} &      \begin{sideways}\textbf{Column 1}\end{sideways} &      \begin{sideways}\textbf{Column 2}\end{sideways} &      \begin{sideways}\textbf{Column 3}\end{sideways} &      \begin{sideways}\textbf{Column 4}\end{sideways} &      \begin{sideways}\textbf{Long Column 1}\end{sideways} &      \begin{sideways}\textbf{Column 5}\end{sideways} &      \begin{sideways}\textbf{Column 6}\end{sideways}\\      \cline{1-9}      \endfirsthead      \caption[]{(continued)}\\      \cline{3-9}      \multicolumn{1}{c}{} &      \multicolumn{1}{c|}{} &      \begin{sideways}\textbf{Column 1}\end{sideways} &      \begin{sideways}\textbf{Column 2}\end{sideways} &      \begin{sideways}\textbf{Column 3}\end{sideways} &      \begin{sideways}\textbf{Column 4}\end{sideways} &      \begin{sideways}\textbf{Long Column 1}\end{sideways} &      \begin{sideways}\textbf{Column 5}\end{sideways} &      \begin{sideways}\textbf{Column 6}\end{sideways}\\      \cline{1-9}      \endhead           % Page footer      \cline{1-9}      \multicolumn{9}{c}{(Continued on next page)} \\      \endfoot           % Last page footer      %\bottomrule      \endlastfoot           \multirow{3}{*}{\begin{sideways}\textbf{R1}\end{sideways}} &      {Place holder text....}&      {}&      {}&      {}&      {}&      {X}&      {}&      {}\\           \cline{2-9}           {}&      {Place holder text....}&      {}&      {X}&      {X}&      {}&      {X}&      {X}&      {X}\\           \cline{1-9}           \multirow{3}{*}{\begin{sideways}\textbf{R2}\end{sideways}} &      {Place holder text....}&      {}&      {}&      {}&      {}&      {X}&      {}&      {}\\           \cline{2-9}           {}&      {Place holder text....}&      {}&      {X}&      {X}&      {}&      {X}&      {X}&      {X}\\            \cline{2-9}           {}&      {Place holder text....}&      {}&      {X}&      {X}&      {}&      {X}&      {X}&      {X}\\           \cline{1-9}          \end{longtable}          \end{document}


title: Column-style bibliography

text: A problem that's been annoying me for years (http://newsgroups.derkeiler.com/Archive/Comp/comp.text.tex/2008-04/msg01387.html) has been how to create a column'ed bibliography. E.g., take a look at the bibliography in: http://www.cgd.ucar.edu/staff/trenbert/trenberth.papers/UppalaERA05.pdf ![enter image description here](http://i.stack.imgur.com/PsvvS.png) That's what I want! Ideally, I'd like four columns (Author, Year, Journal/Source, Title+Pages) rather than the three shown in the example (although that's a start).


title: How to cross-reference to sections in beamer

text: For my lecture slides in `beamer` I would like to establish a section- framenumber numbering scheme. For this purpose I reset frame counter in `\AtBeginSection` and redefine the `\insertframenumber` command to reflect the new numbering scheme:               \renewcommand{\insertframenumber}{\thesection-\theframenumber}     \AtBeginSection{\setcounter{framenumber}{0}}      This works pretty well. However, I have not succeeded in getting cross- references right in this respect, that is to refer to some labeled `\frame[label=interesting]` as section-framenumber. Apparently, there is no way to, given the label, extract the section number:               \documentclass{beamer}          \renewcommand{\insertframenumber}{\thesection-\theframenumber}     \setbeamertemplate{headline}[text line]{This is frame: \insertframenumber}     \AtBeginSection{\setcounter{framenumber}{0}}          \begin{document}          \section{One}     \begin{frame}{First Frame in Section One}       Slide content\par       \pause       More content     \end{frame}     \begin{frame}[label=interesting]{Second Frame in Section One -- The one to crossref to}       Slide content     \end{frame}          \section{Two}     \begin{frame}{First Frame in Section Two}            Now I want to crossref to interesting slide by section-framenumber (that is, somehow generate \textbf{1-2})        \begin{itemize}         \item \textbackslash{}ref yields: \ref{interesting}, apparently that is the frame number         \item \textbackslash{}page yields: \pageref{interesting}, apparently that is the PDF page number         \item \textbackslash{}autoref yields: \autoref{interesting}, apparently that is the frame number again         \item nothing there that yields \textbackslash{}thesection of our target label?       \end{itemize}     \end{frame}          \end{document}      I took a look at the generated `.aux`-file. I am not really good in deciphering `.aux`-files; however, as I read it, beamer does not even store there the section number (1 in this case) the label belongs to:               ...     \newlabel{interesting<1>}{{2}{3}{One\relax }{Doc-Start}{}}     ...      So am I out of luck here? **Edit:** I am now considering looking into the `zref` package to solve my problem. The challenge will probably be to get it integrated with the `label=mylabel` frame option, which implicitly generates those helpful "overlay" labels (`mylabel<1>`, `mylabel<2>`, `...`) to refer to individual slides of a frame. Any hints or ideas still are more than welcome :-)


title: Bibtex references, citing from same reference but different page

text: I am using TeXnicCenter, Miktex 2.9 and have BibTeX for using references (`bibliographystyle{achemso}`). I am writing my master thesis and I would like to refere to the same reference, but with different page related to that reference. I would like to have it like this: > ex. text with references: Hello^1a, how are you^1b How it should look like in the bibliography: >   1. author, title, publisher, year, pages (a) 2-4, (b) 60-78. >


title: recreating biblatex option autocite=footnote,style=verbose-trad1 in bibtex

text: I am currently generating my bibliography as follows:               \usepackage[autocite=footnote,style=verbose-trad1]{biblatex}     \let\cite\autocite      This generates full citations in footnotes, with optional pre- and post-notes. Depressingly, it looks like I'll have to regress to bibTeX for a journal thing, so to make things run smoothly, I'd like to put my house in order before sending off the manuscript. So what are my options? What `\bibliographystyle` should I use so that I get full citations with the `\cite` command? Is there a way to get references as footnotes with bibtex? Or do I have to sed-fu my way to changing my `\cite`s into `\footnote\cite`s with the pre/post notes shifted as needed?


title: Underline at the same level

text: I want to underline alpha's and beta's, but at the same level. I mean, I don't want ![](http://i.stack.imgur.com/vbzQy.png) but ![](http://i.stack.imgur.com/n18fi.png). Maybe there is already a command that make it but I couldn't find it. The second image was obtained with the following command :               $\newlength{\espa}     \settowidth{\espa}{$\alpha$}\rlap{\underline{\hspace{\espa}}}\alpha,     \settowidth{\espa}{$\beta$}\rlap{\underline{\hspace{\espa}}}\beta$      which is hardly working but not totally. In normal math mode, no pbm. In scriptsize (or tiny or anything else) math mode, no pbm. But if I am in math mode within an exponent, then the `\settowidth` command does not seem to take into account that I am in sciptsize mode and, as a matter of fact, the underline is too long ( _e.g._ ![](http://i.stack.imgur.com/31Srf.png)). Any idea ?


title: using more than 2 arguments in a pgfplots style

text: Based on How to plot data from multiple filters using pgfplots I got a follow up one. I would like to filter not only for one value of P for each plot but for also for X values that are smaller than a given value. Here is how I tried to achieve it.                 \pgfplotsset{         discard if not and smaller/.style 4 args={             x filter/.code={                 \edef\tempa{\thisrow{#1}}                 \edef\tempb{#2}                 \edef\tempc{\thisrow{#3}}                 \edef\tempd{#4}                 \ifnum\tempa=\tempb                     \ifnum\tempc<\tempd                         \def\pgfmathresult{inf}                     \else                     \fi                 \else                     \def\pgfmathresult{inf}                 \fi             }         }         }              \begin{tikzpicture}         \begin{axis}         \addplot [ultra thick, black, discard if not and smaller={P}{0}{X}{5}] table [x=X, y=Y] {data.dat};         \end{tikzpicture}      But pdfLaTeX tells me that:               ! Package pgfkeys Error: I do not know the key '/pgfplots/discard if not and sm     aller/.style 4 args' and I am going to ignore it. Perhaps you misspelled it.      How can I pass these 4 arguments so that pgfplots find the style definition?


title: How to make the equation very extended bold?

text: How could choose the level of boldness? The difficult point is that it is not bold the text. Any idea?               \documentclass{article}     \usepackage{amsmath,bm}               \begin{document}               \boldmath\boldmath\boldmath{\boldmath     \fbox{     \begin{minipage}[c]{\textwidth}%     $\bullet$ Initialization: $x^0 \in X$, $\lambda \in R$          $\bullet$ Iterations $n\ge 0$: Update $\tau^n$, $\widehat{x}^n$ and $x^n$ as follows     \begin{equation}         x=y\end{equation}     \end{minipage}     }}     \end{document}


title: Using mathdesign for TeX Live 2012 with TeX Live 2013 and the latest MiKTeX

text: For some reason, I need the old version of `mathdesign` (the one shipped with TeX Live 2012) to work smoothly with TeX Live 2013. Ideally, I'd like to be able to switch from one version to the other. Note that I still have TeX Live 2012 installed. How can I do that? (I run a Debian box.) For the same reason, a colleague needs the old version to work with the latest version of MiMTeX. How can he do that?


title: How can I modify abbrvnat.bst to have unsorted reference list using natbib?

text: I like the way `abbrvnat.bst` prints the reference list using the package `natbib`. Unfortunately, it does sort the list alphabetically. How can I modify it such that it prevents the bibliography from being sorted? I want to order citations by appearance. I tried commenting out `ITERATE` and `SORT` in the file `abbrvnat.bst` but it did not work. If I use `ieeetr`, my problem is solved. However, I have to stick with `natbib` `.bst` files because other `.bst` files such as `ieeetr` are not compatible with `classicthesis` package that I am using. I should only modify `abbrvnat.bst`. I also compared it with the other .bst but I didn't find it trivial what to modify. Could someone please help me? * * * Here the working example:               % arara: pdflatex     % arara: bibtex     % arara: pdflatex     % arara: pdflatex     \RequirePackage{filecontents}     \begin{filecontents*}{\jobname.bib}     @preamble{ "\newcommand{\noopsort}[1]{} "}     @ARTICLE{article-full,        author = {L[eslie] A. Aamport},        title = {The Gnats and Gnus Document Preparation System},        journal = {\mbox{G-Animal's} Journal},        year = 1986,        volume = 41,        number = 7,        pages = "73+",        month = jul,        note = "This is a full ARTICLE entry",     }     @BOOK{book-full,        author = "Donald E. Knuth",        title = "Seminumerical Algorithms",        volume = 2,        series = "The Art of Computer Programming",        publisher = "Addison-Wesley",        address = "Reading, Massachusetts",        edition = "Second",        month = "10~" # jan,        year = "1981",        note = "This is a full BOOK entry",     }     @MISC{misc-full,        author = "Joe-Bob Missilany",        title = "Handing out random pamphlets in airports",        howpublished = "Handed out at O'Hare",        month = oct,        year = 1984,        note = "This is a full MISC entry",     }     \end{filecontents*}          \documentclass[]{article}     \usepackage[numbers]{natbib}     \begin{document}     \cite{misc-full}     \cite{article-full}     \cite{book-full}          \bibliographystyle{abbrvunsrtnat}     \bibliography{\jobname}     \end{document}


title: Why I shouldn't load pdftex option with hyperref?

text: According to @percusse in this post, I shouldn't load the `pdftex` option with the `hyperref` package. Why is it?


title: Bold Y-Tick Label and Every Node Near Coord

text: I can make my `xticklabel` apply `\bfseries`, I can make my `xlabel` and `ylabel` apply `\bfseries`. For some reason, I cannot seem to get my `yticklabel` to apply this effect. At least when I compare the "1" in my `xticklabel`, it is clearly different than that in my `yticklabel`. Fairly related, but happy to split into a 2nd question, is applying the same bold weight to the `every node near coord/.append style`. I do believe that these values are generated in mathmode, so I am not surprised I was not successful in applying a standard `\bfseries` weight to them. But if someone could provide a solution to that as well, it would be great. I did try, based on zero understanding of the inner workings, to use the `etoolbox` package and `\robustify\bfseries` without effect.               \documentclass[letterpaper]{article}     \usepackage{graphicx}     \usepackage{pgfplots}     \usepackage{xcolor}     \pagecolor{black}     \usepackage{siunitx}     %This didn't work either     %\usepackage{etoolbox}     %\robustify\bfseries     \sisetup{inter-unit-product={}\cdot{},sticky-per=true,multi-part-units=single,%     separate-uncertainty=true,list-units=single,range-units=single,detect-all,%     detect-weight=true,detect-inline-weight=math}          \DeclareSIUnit\calorie{cal}     \DeclareSIUnit\kcal{\kilo\calorie}     \DeclareSIUnit\kcalpmole{kcal\per\mole}          \definecolor{hoyemagenta}{HTML}{FF3FFF}     \definecolor{hoyegreen}{HTML}{31FF31}     %\usepgfplotslibrary{external}     %\tikzexternalize[shell escape=-enable-write18]     %\tikzset{external/system call={latex \tikzexternalcheckshellescape -halt-on-error %     %-interaction=batchmode -jobname "\image" "\texsource" && dvips -o "\image".ps %     %"\image".dvi}}     \begin{document}     \begin{tikzpicture}         \begin{axis}[             color=white,             width=450pt,             ybar, bar shift=0pt, bar width=12,             enlarge x limits=0.07,             ylabel={Free Energy Difference (\si{\kcalpmole})},             xlabel={Trapping Product},             label style={color=white,font=\bfseries},             xtick={1,2,3,4,5,6,7,8,9,10,11,12},             every axis/.style={color=white},             ymax=40,             ymin=-110,     %       I also tried manually setting the ticks, in hopes that would trigger the change             %       ytick={-100,-80,-60,-40,-20,0,20,40},             xtick pos=left,             nodes near coords,             %Here I tried setting \bfseries for my nodes without success             every node near coord/.append style={font=\bfseries,%             /pgf/number format/.cd,             fixed,             fixed zerofill,             precision=2},             nodes near coords align={vertical},             tick label style={font=\bfseries\Large},            %        y tick label style={color=white,font=\bfseries},     %       I used to just have this x tick label style line below, then I tried the separate y tick label style     %       and also the tick label style above that     %        x tick label style={anchor=center,yshift=-6pt,color=white,font=\bfseries\large},             symbolic x coords={1,2,3,4,5,6,7,8,9,10,11,12}             ]             \addplot[fill=hoyegreen,]             coordinates{             (1,-48.93)             (3,-13.62)             (6,-46.85)             (8,-42.27)             (10,-55.74)};             \addplot[fill=hoyemagenta]             coordinates{                     (2,-26.90)             (4,31.78)             (5,-49.25)             (7,-49.71)             (9,-44.14)             (11,-51.07)};             \addplot[fill=yellow]             coordinates{(12,-97.69)};         \end{axis}     \end{tikzpicture}     \end{document}


title: How can I install just pdfTeX and pdfLaTeX without additional stuff on a mac?

text: I am trying to install just pdfLaTeX without the rest of the stuff that comes in packages such as MacTeX. All I want to be able to do is convert LaTeX source files into pdf's. I downloaded the pdfTeX package from http://www.tug.org/applications/pdftex/ and followed the directions to install it, but I couldn't do it properly. Can I create pdf files out of LaTeX source files with just pdfLaTeX? Also how do I install it?


title: Splitting page into four parts

text: I am trying to figure out how to split a page into four quadrants (2 rows and 2 columns) to model the time management matrix. I tried using longtable but the second row will only start after the first. What I want to do is to have fixed size rows and columns on each page and contents from particular cell should overflow to corresponding cell on next page w/o resizing the row. I had similar issue with minipage. This is what I have right now,               \documentclass{article}          \usepackage{lipsum}     \usepackage{longtable}          \begin{document}          \begin{longtable}{p{0.5\textwidth}|p{0.4\textwidth}}         \endfirsthead         \endhead         \endfoot         \endlastfoot              \lipsum[2] & \lipsum[1] \\         \hline         \lipsum[3] & \\     \end{longtable}          \end{document}      There is another similar question but there the text from cell 1 flows into cell 2 on same page. This is not what I want. **Edit** : An example of what I would like to do is to add content to cell (1,1) on page 1. When the cell is full, the contents should continue to cell (1,1) on page 2 even if other cells on page 1 are empty.


title: Is xskak compatible with wrapfig?

text: I would like to show some (chess) moves, wrapping them around the resulting chessboard. The following code:               \documentclass[twocolumn]{article}          \usepackage{xskak}     \usepackage{wrapfig}     \usepackage{lipsum}     %\raggedright          \begin{document}          \newchessgame          \setchessboard{tinyboard,       showmover=false,       marginwidth=0pt,       labelleft=false,       labelbottom=false}          \hidemoves{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1       b5 7. Bb3 O-O 8. a4 Bb7 9. d3 Re8 10. Nbd2 Bf8}          \begin{wrapfigure}{r}{80pt}       \chessboard     \end{wrapfigure}     %\lipsum[1]     \variation{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1        b5 7. Bb3 O-O 8. a4 Bb7 9. d3 Re8 10. Nbd2 Bf8}          \end{document}      produces the following, where the moves get in the way of the board. However, normal text flows nicely, as you can see uncommenting the lipsum line. How could I get the moves to flow around the board? ![enter image description here](http://i.stack.imgur.com/CK8D6.png)


title: Why do I have to put fillcolor setting inside preview environment?

text: It seems to me this problem related to PSTricks so I have to modify the previous question. `\psset{fillstyle=solid,linecolor=red}` that I define globally outside the `preview` environment can affect the graphics object. But why do I have to put `\psset{fillcolor=green}` inside the `preview` environment to make it works?               \documentclass[preview,border=12pt]{standalone}     \usepackage{pstricks}     \psset{fillstyle=solid,linecolor=red}          % the following setting will be ignored by preview     % \psset{fillcolor=green}          \begin{document}     \preview     % Thus the setting must be inside the preview, does it seem strange to you?     \psset{fillcolor=green}     \psframebox{Karl's students}     \endpreview     \end{document}      Is `fillcolor` very special in this case?


title: Title over align columns

text: Using the `align` environment I have two columns, one for derivation, and another for the rule that was used to create the derivation. However I'm pretty sure that there's a better way to do this? Here is what I came up with:               \documentclass[fleqn]{article}     \usepackage{amsmath}     \usepackage[fleqn]{mathtools}     \begin{document}     \begin{itemize}     \item \begin{align*}     D&erivation\; &&Rule\\     S&\implies aA& S&\rightarrow aA\\     &\xRightarrow{i-1} a^iA&A&\rightarrow aA\\     &\implies a^ibB&A&\rightarrow bB\\     &\xRightarrow{j-2} a^bb^{j-2}B&B&\rightarrow bB\\     &\implies a^ibb^{j-2}b&B&\rightarrow b\\     &=a^ib^j     \end{align*}     \end{itemize}     \end{document}


title: Typesetting a song inside a non-fiction book

text: In several places in a book, I need to quote songs. I've tried the `verse` environment, but it doesn't really look great:               \begin{verse}     Douce nuit! Sainte nuit!\\     Tout se tait, l'heure fuit.\\     Seuls Joseph et Marie humblement,\\     sont penchés au berceau de l'Enfant.\\     Dors, Jésus radieux!\\     Dors, Jésus radieux!          Douce nuit! Sainte nuit!\\     Rois, bergers vont à Lui.\\     L'air s'emplit de cantiques joyeux,\\     qui s'envolent aux portes des cieux.\\     C'est Jésus le Sauveur!\\     C'est Jésus le Sauveur!          Douce nuit! Sainte nuit!\\     Où Jésus a souri.\\     Son amour jusqu'à nous est venu!\\     L'âme en Lui trouve enfin le salut!\\     Christ au monde est donné!\\     Christ au monde est donné!          (Traduction Denereaz)     \end{verse}      ![a song typeset using verse](http://i.stack.imgur.com/eWAGr.png) What would you recommend using to typeset this?


title: How to pass a node to \psGetDistance?

text: I want to handle the bug mentioned in my previous question. However, the following MWE produces an error. My prediction is that `\psGetDistance` seems to reject nodes as its arguments.               \documentclass[pstricks,border=12pt]{standalone}     \usepackage{pstricks-add}     \begin{document}     \multido{\i=0+30}{12}{%     \begin{pspicture}(-2,-2)(2,2)         \pscircle{1}         \pnode(1;\i){R}         \psset{arrows=->}         \psline(R)         \psGetDistance(0,0)(R|0,0)\Distance         \ifnum\Distance=0\relax         \else             \psline[linecolor=blue](R|0,0)         \fi         \psGetDistance(0,0)(0,0|R)\Distance         \ifnum\Distance=0\relax         \else             \psline[linecolor=red](0,0|R)         \fi         \psset{linecolor=gray,linestyle=dashed,linewidth=0.5\pslinewidth,arrows=-,dash=2pt 2pt}         \psline(R)(0,0|R)         \psline(R)(R|0,0)     \end{pspicture}}     \end{document}      How to pass a node to `\psGetDistance`?


title: Shades of colors

text: I have defined a new color with `\definecolor{MyBlue}{rgb}{0.25,0.5,0.75}`. Is it possible to define now "derivatives" of this in term of shades? I would like to use the same color in three different shades. It is possible to do this with grey by default, but can I define one mu own? Like               \definecolor{NextBlue}{MuBlue}{0.75}      I use the `xcolor` package.


title: How to preserve relative spacing when changing paper size in beamerposter. (margins too big)

text: I recently made a poster in LaTeX using the `beamerposter` package, it was 48x36 inches, and came out great. I now need to re-print the poster in a smaller size. (36x24 inches) I realize that this changes the aspect ratio, and I'll have to finagle the layout a bit - but before i can do that i need all of the columns and the spaces between them to be the right size. There are a number of `\setlength` commands at the top of the file, which I assumed would take care of this:               \newlength{\sepwid}     \newlength{\onecolwid}     \newlength{\twocolwid}     \newlength{\threecolwid}     \setlength{\paperwidth}{48in}     \setlength{\paperheight}{36in}     \setlength{\sepwid}{0.024\paperwidth}     \setlength{\onecolwid}{0.22\paperwidth}     \setlength{\twocolwid}{0.464\paperwidth}     \setlength{\threecolwid}{0.708\paperwidth}     \setlength{\topmargin}{-0.5in}      When I make the `\paperwidth` anything other than 48, the paper size (in preview) does change, but the `\sepwid` width doesn't scale appropriately. Specifically, when I reduce the paper width to 36 inches, the columns end up being the correct size, but the space between them is closer to `0.1\paperwidth` instead of `0.24\paperwidth`, which results in huge spaces between columns. What is LaTeX doing? How do I fix this? ...I also use the following packages in the poster: `exscale`, `caption`, `subcaption`, `wrapfig`, `natbib` For a working example, download the zip file here: http://www.njohnston.ca/2009/08/latex-poster-template/, and change the dimensions in that example from 48x36 to 36x24.


title: Two figures side-by-side with inequal height and aligned captions

text: I have an addition to this question: Two figures side by side. Suppose we have two pictures, making them of uneven height. I am looking for a way to _not_ use `subfig` and align two figures side-by-side, while keeping the captions vertically aligned. I've created the following example:               \documentclass{article}     \title{Two Figures Side by Side}     \author{Little Bobby Tables}     \usepackage{lipsum}     \usepackage{tikz}          \newcommand{\exedout}{     \begin{tikzpicture}     \path node (LL) {}         ++ (0.8\textwidth, 0.8\textheight) node (UR) {}         (LL -| UR) node (LR) {}         (LL |- UR) node (UL) {};     \draw (LL) rectangle (UR) (LL) -- (UR) (UL) -- (LR);     \end{tikzpicture}     }          \newcommand{\exedouttwo}{     \begin{tikzpicture}     \path node (LL) {}         ++ (0.8\textwidth, 0.4\textheight) node (UR) {}         (LL -| UR) node (LR) {}         (LL |- UR) node (UL) {};     \draw (LL) rectangle (UR) (LL) -- (UR) (UL) -- (LR);     \end{tikzpicture}     }     \begin{document}     \maketitle     How can I put two figures side-by-side? Not two sub-figures, but two actual figures     with separate "Fig.: bla bla" captions. A figure is supposed to spread over the     entire text width, but I have two figures which are narrow and long, and I need to     save the space in order to withstand the pages limit.          \lipsum          \begin{figure}     \centering     \begin{minipage}{0.45\textwidth}     \centering\exedout     \caption{first figure but with more comments than the second picture to see what the different is.}     \end{minipage}     \begin{minipage}{0.45\textwidth}     \centering\exedouttwo     \caption{second figure}     \end{minipage}     \end{figure}          \lipsum          \end{document}      It gives the following result: ![wrong alignment](http://i.stack.imgur.com/CIsI7.png) But I need this: ![right alignment](http://i.stack.imgur.com/ytzPQ.png)


title: Double square braces like these ⟦exp⟧?

text: How do I create mathematical equation double square braces like these ⟦exp⟧ in latex? I failed to find it on google (I created these using word 2010 equation editor). I would like these to be of adjustable height like regular braces if possible. Thanks in advance!


title: Listings code snippet has white horizontal lines across it

text: I'm using the `listings` package to typeset my code examples. I've set the background color to slightly off white color and I'm noticing strange white horizontal lines across the snippet. They seem to go right between every line. Not sure if I should include my `listings` settings? ![Listings bug](http://i.stack.imgur.com/aRAsM.png)