Tag Info

Hot answers tagged

81

Latexmk is one possibility, although I've never used it myself.


67

Here's a hacky way, probably this is the wrong way :). Instead of passing a filename, you can pass a sequence of commands. So in particular, you could do something like pdflatex "\def\ishandout{1} \input{foo.tex}" which defines the macro \ishandout (to be 1) and then reads foo.tex. And then, inside foo.tex, you can check whether \ishandout is defined: ...


49

Try Arara. It also has a great manual. \expandafter\thecomment Arara provides us with ways (rules) to compile the document that are specific to the document. The rules for compilation are put inside the document. Hence, compilation boils down to a simple arara yourtexfile. First, install arara and make sure that the arara executable is included in system ...


46

You can use the following tools to do this. All of them are on CTAN but not all of them are part of either TeXLive or MikTeX, so you may need to manually install them. They need either Perl or a C compiler installed. Both should not be a problem with Linux but might be one under Windows or Mac. However IIRC TeXLive installs its own Perl interpreter. ...


42

Yes, there are packages called svn and svninfo, as well as a few for other version-control systems. See the UK TeX FAQ: you can have something like \SVNdate $Date$ which will use the value of the Date SVN variable in your document, or have footers containing the date and version number in the document. I don't think either of them shows diffs, though.


37

The TikZ 2.10 library, external, addresses this issue. Externalizing all TikZ graphics in a LaTeX document is as easy as: \usetikzlibrary{external} \tikzexternalize If your document is named report.tex, this will dump out a series of images: report-figure0.pdf, report-figure1.pdf, etc, etc. To get a more manageable output, you can specify a directory ...


37

Advantage If you use biblatex or multiple languages with babel or polyglossia, you can benefit from the integrated commands of csquotes. There are commands to quote in languages other than the main language so that the quoted text is typeset in accordance with the rules of the language. There are also commands to make formal quotes, both in the main ...


37

Here's a TikZ picture producing the USA map. I produced it as follows: I downloaded the svg map from wikipedia I used Inkscape to translate the svg to tikz code (in verbose mode) the verbose mode annotated the paths with the abbreviated names of the states so I just copied the names and put them as the style of each path (you can do it with a regex) I ...


36

For systems like CVS or Subversion, which modify source files, the TeX FAQ's bare-bones answer is my favourite: \def\RCS$#1: #2 ${\expandafter\def\csname RCS#1\endcsname{#2}} \RCS$Revision: 1.13 $ % or any RCS keyword \RCS$Date: 2010/04/02 18:20:00 $ ... \date{Revision \RCSRevision, \RCSDate} It's not very sophisticated, but you're only going to use it ...


31

Do I really need to go over everything and add \index{}? Unfortunately yes. At best even if you write a script to automate it you will end up with a concordance, and a concordance is not an index. In my opinion it is actually better to postpone the writing of the index to the time the book is almost ready. Writing an index is an art and most ...


30

You need to write a configuration file that tells latexmk which files are interesting for the glossary and how to handle them. Fortunately, the author provides some sample rc files. Putting add_cus_dep('glo', 'gls', 0, 'makeglo2gls'); sub makeglo2gls { system("makeindex -s '$_[0]'.ist -t '$_[0]'.glg -o '$_[0]'.gls '$_[0]'.glo"); } in ~/.latexmkrc ...


30

For the last part of your question, I like the Perl script latexdiff. This generates LaTeX documents displaying linebreak-insensitive differences, with changebars and other visual markup. (Alas, the implementation is quite hacky, relying on complex regular expressions for parsing, so it's worth ensuring one has Perl 5.8.10 or later installed for greater ...


29

There is a tool named Rubber. It is for instance used by Gedit LaTeX plugin. It should recognize which tools to run (BibTeX, makeindex...) and run (pdf)latex and them in right order and how many times it is needed to converge to the ready file. It behaves like make, i.e. it does not recreate files that it thinks won't change recompiled (this can be omitted ...


29

Well even if I know which quotes I want to use in a document: I would find it painful to remember which quotes and keyboard keys to use in an English text, and which in the German and whatever a Frenchman must use in a French text. Actually at the time csquotes appeared I was just thinking about a generic system to relieve me from trying to remember which of ...


29

The pgffor package allows for-loop style repetition using the following format: \foreach \<cmd> in {1,...,<total>} {% % stuff } Using this as base, the following is probably what you're after: \documentclass{beamer}% http://ctan.org/pkg/beamer \usepackage{graphicx}% http://ctan.org/pkg/graphicx \usepackage{pgffor}% ...


29

At Hans-Peter E. Kristiansen’s request, I provide another answer, extending the one given by kay102. Add the following lines to some latexmk initialization file (e.g., on Linux systems, ~/.latexmkrc): add_cus_dep('glo', 'gls', 0, 'run_makeglossaries'); add_cus_dep('acn', 'acr', 0, 'run_makeglossaries'); sub run_makeglossaries { if ( $silent ) { ...


29

Newer versions of Ghostscript (version 9.05 and later) include a "device" called inkcov. It calculates the ink coverage of each page (not for each image) in Cyan (C), Magenta (M), Yellow (Y) and Black (K) values, where 0.00000 means 0%, and 1.00000 means 100%. Example commandline: gs -o - -sDEVICE=inkcov /path/to/your.pdf Example output: Page 1 0.00000 ...


28

I did a large amount of research for a very similar StackOverflow question. To summarize the problems of each tool: latexmk will overwrite your document in place, frequently causing your viewer to display an incomplete document (eg when there are errors). Its error support is bad. rubber will overwrite your document in place (see above). It also frequently ...


27

Not much of an answer, more a couple of loose thoughts ... Off-hand I'm not aware of any such system and also not aware of any research that deals with automatic newspaper layout. As far as I know there has been only very very limited attempts to approach the subject of automatic typesetting with more complex layout rules and dependencies that go beyond ...


27

For Git and Mercurial the only packaged option for writing revision information to the output document is the vc-bundle, which works without keyword substitution by writing to an \input’ed file. For rendering a diff document a commit hook could be used that calls latexdiff-vc. Just inspecting diffs word-based instead of line based can be done with wdiff, or ...


27

You can use a vertical alignment to get the measuring done and then re-flow them in a horizontal layout: \documentclass{article} \usepackage[leqno]{amsmath} \renewcommand\theequation{\alph{equation}} \newenvironment{brqalign}{% % START CODE %%%%%%%%%%%% % Do everything an a box, as you can not remove % things from the main vertical list. ...


26

Here's an attempt in Metapost. Using the direction x of y macro to find the required angle of reflection. Here's what you get with r=0: And with r=0.33: prologues := 3; outputtemplate := "%j%c.eps"; beginfig(1); path base, ray[]; u = 5mm; r=0.33; base = (-6u,0) for x=-5.8u step 0.2u until 5.8u: -- (x,r*normaldeviate) endfor -- (6u,0); draw ...


24

It has always been a possibility although obviously the document markup side of latex is mostly aimed at hand authored documents, but even back while 2e was being developed there were wysiwyg systems like sw that are essentially generating latex that isn't touched and latex is often used for typesetting from XML (or previously SGML) using xslt or dsssl or ...


24

The ability to define complex macros is one of the strengths of LaTeX. The traditional LaTeX way would be to use \p{x}{y} in the text instead of \p(x)(y). If you are happy with \p{x}{y}, then you can just add \newcommand{\p}[2]{\frac{\partial#1}{\partial#2}} to your preamble. Since this new macro is requires mathmode, you may also want to wrap the macro ...


23

How about using a chunk with <<results=tex, echo=FALSE>>=? It will allow you to: (a) paste together the LaTeX code you'd like to run (i.e. 200 \begin{frame} ... \includegraphics ... \end{frame} constructs); and (b) place that constructed text verbatim in the *.tex file produced by Sweave(). For more details, see here. It's a FAQ! ...


22

See the needspace package. It might do what you need, or at least give inspiration for whatever it is you're trying to do :-) Namely, the \pagegoal and \pagetotal registers should help.


22

A package? The following simple macro does it: \documentclass{article} \newcount\smcount \def\smart#1{\ifcase\smcount(\or[\or\{\else TOO DEEP!\fi% \advance\smcount by1 #1\ifcase\smcount\or)\or]\or\}\else TOO DEEP!\fi% \advance\smcount by-1 } \begin{document} \smart{Ala \smart{ma \smart {kota}}} \end{document} (Or, if you wish, not \smart but ...


21

\documentclass{article} \usepackage{amsmath} \newcommand\p[2]{\frac{\partial #1}{\partial #2}} \begin{document} $ \p{x}{y} $ \end{document}


21

I have the following function in my $VIM/ftplugin/context.vim file to format ConTeXt paragraphs (same as LaTeX: the environments are enclosed in \start... and \stop... instead of \begin{...} and \end{...}. It should be easy to adapt this to LaTeX (In fact, I think that I copied it originally from someone who had written it for LaTeX and adapted it to ...


20

Have the target in your Makefile clobber a file that is \input by your Latex document, which, say, sets or resets a \newif conditional. For example, let the Makefile run echo "\handouttrue">flags.tex; latex manuscript on the handout goal. Then manuscript.tex might begin: \newif\handout \input{flags} \documentclass...



Only top voted, non community-wiki answers of a minimum length are eligible