Tag Info

Hot answers tagged


Spacing is wrong. It is a "deadly sin" according to l2tabu, section 1.6 on page 6: http://www.ctan.org/tex-archive/info/l2tabu/english/


The short answer is what others have said, % starts a comment that goes to the end of the line. The normal effect is that it doesn't insert the space (or a \par) from the newline. The longer answer is that as TeX parses its input, it reads the input file line by line. It strips off tailing whitespace (including any carriage return and newline) and then ...


Note that you shouldn't use \(...\) unless you also load the fixltx2e package. By default, \( and \) are fragile commands and cannot be used inside section headings or captions.


\( ... \) is LaTeX syntax. $ ... $ is TeX syntax. plainTeX only allows $. In LaTeX you can use both, but \( ... \) will give less obscure error messages when there is a mistake inside it. Both are shortcuts to start inline math environments.


Here is one more reason (this is what converted me). If you use the \begin{proof}...\end{proof} environment, you occasionally end a proof with an equation. The automatic QED box then ends up on a line by itself, which is ugly. You can fix this by writing \qedhere at the end of the equation, but this doesn't work properly with $$...$$ – you have to use ...


$$ is TeX primitive syntax, which, as others have commented is hard to redefine (in classic TeX there is no command name which triggers entering or leaving display math). LaTeX doesn't officially support $$. The most noticeable failure if you use the syntax is that the fleqn option will no longer affect the display of the mathematics, it will remain ...


\par is a Tex primitive and is the same as a blank line (except in special environments such as verbatim where the usual rules don't apply). It ends horizontal mode, causes TeX to break the horizontal text into lines placed on the current vertical list, and exercises the page breaker which may possibly cause the next page to be shipped out. \\ is different ...


The short answer is you use \verb where you need to write a small piece of inline verbatim material that contains characters TeX treats (or rather, is currently treating) as special. \texttt is for when you just want typewriter font. \verb has some downsides, such as not working in moving arguments. In those cases, you're probably better off using \texttt ...


While listings package is good, it has some deficiencies, especially in Unicode support. I'd recommend trying out minted, which uses the output of Pygments, which is more likely to get grammar updates than listings.


I have no problem with publisher = {Harold \& Maude}, and running pdflatex and bibtex.


Anyone who's ever tried writing a simple perl (or whatever) script to quickly parse a LaTeX document and do something in maths mode but not in text mode will agree that \( .. \) is the only way to go! Trying to get the pattern matching right against $a^2 + b^2$$c^2 + d^2$ is a nightmare. (Before anyone asks, yes I have, and it's called mathgrep. The pain ...


General tips Use as few packages as possible, Call the packages in particular order, Use many small documents instead of one big one, Comment your code, Write readable code, Concentrate on the content, not on the appearance. General tips somewhat explained That's because packages tend to conflict and go obsolete. (See How to keep up with packages and ...


The standard way of doing this is to use the listings package. It allows a wide range of formatting for the output, can choose to display only part of an input file and so on. The package also comes with a number of predefined languages it understands, including Python.


The tilde ~ is an unbreakable space, i.e. the line will never be broken at this position. If you write Table~\ref{...} the table number generated by \ref will always be on the same line as Table, which is the preferable formatting. Having "Table" at the end of a line and then "1" at the beginning of the next simply looks bad. The tilde is also used in names ...


Code should be readable and understandable. Using braces for all arguments, even if they aren't necessary, is more consistent. So, I prefer to use braces to not confuse unexperienced users. Leslie Lamport writes in LaTeX - A Document Preparation System: "Macho TeX programmers sometimes remove the braces around the first argument of \newcommand; don't do it ...


I think things are just a bit more complicated than in @Joseph's answer. (Though in laying them out, I may violate the desire for a "concise" answer.) My go to reference for details of the BibTeX format is Norman Walsh's page which self describes as: This help entry contains the same information as Appendix B of the LaTeX manual. In BibTeX's world ...


There is a standard. It's a matter of opinion whether it's sensible or not, but it's been there since the release of LaTeX2e. Font aspect changing commands have two forms: action and declaration The same holds for abstract instruction such as "emphasize" Size changing commands have only the declarative form. Let me review the three points. Font aspect ...


\documentclass{article} \catcode`\|=13 % make | active \def|#1|{\emph{#1}} \begin{document} This is an \emph{important} test. This is an |important| test. \end{document}


What's easy to read for one person is not necessarily easy to read for another. Personally I find: \newcommand{\foo}{foo} much easier to read than: \newcommand\foo{foo} In particular, it clearly reveals what the two arguments to the function are, which the latter does not.


$$ is plain TeX and could have some side effects, also fleqn will not work anymore. Please have a look at l2tabu. In my opinion the best environment for equations is gather or align. If you use equation you sometimes get some strange spacings.


LaTeX's optional arguments viz TeX's macro arguments (delimited and undelimited) The LaTeX concept of optional arguments (i.e., arguments that may or may not been used) is a concept that is not directly supported by TeX's parsing and execution. TeX macros always expect the same number of arguments with the same syntax for delimiting the argument. Optional ...


With my LaTeX3 'hat' on, I'd like to give a slightly different perspective. This will overlap with the other answers, but hopefully will be useful. To follow this you need to understand 'tokens', I'm afraid. TeX turns input into tokens, and in particular control sequences such as \bar are single tokens. When Leslie Lamport designed LaTeX, he decided that ...


Loading the strict package prevents using LaTeX's declarations as environments. Loading the fixltx2e package fixes some LaTeX2e errors. fixmath changes LaTeX's default math style to comply with some international standards, specifically regarding Greek letters, see package description. There are many packages improving LaTeX's standard behavior, for example ...


For a programmer, I would recommend reading the book "TeX by Topic" (available for free at http://www.eijkhout.net/tbt/). I think that that will give you the best answer to your general questions (which really are, in my opinion, a bit too general for this site; I would advise you to read TbT and then ask more focussed questions on particular aspects). ...


You need to give the 'sub-language' for TeX: language = [LaTeX]{TeX} As you are writing a package, you might also want to use the moretexcs key to add 'new' LaTeX commands. For example, in my siunitx I have very long list: moretexcs = { addto, ampere, ang, angstrom, ... to cover all of the new macros it adds, ...


Good approach is defining new environments for programming language. Minimal setup can be around this: \documentclass[a4paper,12pt]{article} \usepackage[utf8]{inputenc} % Default fixed font does not support bold face \DeclareFixedFont{\ttb}{T1}{txtt}{bx}{n}{12} % for bold \DeclareFixedFont{\ttm}{T1}{txtt}{m}{n}{12} % for normal % Custom colors ...


A percent sign, %, allows to end a line without generating a space character -- very useful when writing macros.


Programing fixltx2e is essential etoolbox provides some functionality that one can only get from hacking LaTeX kernel or using the internal macros otherwise. Also it provides some useful document and environment hooks xspace is a tiny but useful macro for defining text oriented macros geometry, typearea, etc, use one and only one of them. The same ...


You could just go: \catcode`\|=\active \def|#1|{\emph{#1}} Then you can use |text| as if it were \emph{text}.


$((a\implies b) \land (c\implies a)) \implies (c \implies b)$ \land and \wedge are synonymous.

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