Hot answers tagged


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 ...


$$ 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 ...


Spacing is wrong. It is a "deadly sin" according to l2tabu, section 1.6 on page 6:


\( ... \) 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.


Note that if your LaTeX installation is older than 2015, you shouldn't use \(...\) unless you also load the fixltx2e package. By default, \( and \) were fragile commands and couldn't be used inside section headings or captions.


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 \...


\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 (...


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


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 \...


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 ...


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 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 ...


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 ...


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.


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.


You can use a combination of \stackrel and \mathclap (from the mathtools package): \documentclass{article} \usepackage{mathtools} \newcommand\myeq{\stackrel{\mathclap{\normalfont\mbox{def}}}{=}} \begin{document} \begin{align*} a &\myeq b \\ &=c \\ &= d. \end{align*} \end{document} If using mathtools is not an option, you can use a \...


You already got lots of answers. You can also just experiment yourself: \documentclass{article} \begin{document} Hello% world! \end{document} Try compiling this with and without the %. Then you see yourself that the % makes the space produced by the newline disappear. (Note that you'll still get the space if you write Hello % with a space before the % &...


$$ 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.


Not equal can be written as: \neq


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 ...


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


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 ...


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


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.


The syntax package from the mdwtools bundle has simple ways of typesetting BNF grammars, with some reasonable controls over how the rules are formatted. The space between grammar rules can be set with the \grammarparsep length. This is a rubber length, and defaults to 8pt plus 1pt minus 1pt. The distance between the left hand side of the production rule ...


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 ...


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 ...


\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}


Historically there has been a lot of confusion over the two forms, (the situation with \phi and \varphi is similar but even more confused as at one point Unicode swapped the reference glyphs). I added a special section about epsilon to the XML/HTML entities spec The situation in TeX is no different really, ...

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