# Tag Info

92

Use the options breaklines=true and postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space} for placing a red arrow at the beginning of the broken line to emphasize the line break. \documentclass{article} \usepackage{lmodern} % for bold teletype font \usepackage{amsmath} % for \hookrightarrow \usepackage{xcolor} % for \textcolor \usepackage{listings} \...

74


61

There was a talk at TUG'11 exactly about this: Didier Verna, Toward LaTeX coding standards: The paper is available for TUG members only till the end of the year, but the video is available for all. Take a look: Didier has many interesting thoughts to offer. You might be also interested in Chris Rowley's talk at TUG'09. And please consider joining TUG: ...

55

The LaTeX book consistently uses {} in all cases so all the examples use that form, you always see a^{2} even though everyone knows that a^2 works just as well and arguably improves the look of the source. When the command taking the argument is a macro and the argument is necessarily a single token, most people drop the brackets as a matter of course so \...

54

Many text-comparing tools like diff use line-by-line comparison. This can be explained by their origin as programmers' tools. When lines are short enough, these tools work well with TeX sources - especially when combined with version control systems. Of course, there are tools like latexdiff (highly recommended!), which do not take into account line ...

51

There are a few places in TeX where braces are a required part of the syntax but those are few. When it comes down to arguments then TeX accepts a single token without surounding braces so \mathrm i would work if "typeset". But try this: \newcommand\x{log} \tableofcontents \section{$\mathrm \x$} and you will get a subtle error in your output (but no ...

43

(Disclaimer: The question clearly says "even when the result is the same", which I answer by saying that when the result is the same, the result is the same. However, there are (numerous) examples when the result is not the same, see e.g. Frank Mittelbach's answer!) There is only one valid answer in my opinion: From the TeX's point of view, if there is no ...

42

This is how I would do it: General indent by three spaces (I find that two spaces don't stand out enough...) use Tab to indent or hard code with three spaces use more new lines to structure code than less, i.e. prefer \newcommand{\mycmd}[1]{% \par\addvspace{\baselineskip}% \noindent My Text:~% \parbox[t]{0.6\textwdith}{% \textbf{#1} }%...

33

As you can see from du -sch /usr/local/texlive/2012/texmf-dist/* 16M /usr/local/texlive/2012/texmf-dist/bibtex 1008K /usr/local/texlive/2012/texmf-dist/context 1,5G /usr/local/texlive/2012/texmf-dist/doc 6,6M /usr/local/texlive/2012/texmf-dist/dvips 1,4G /usr/local/texlive/2012/texmf-dist/fonts 1,9M /usr/local/texlive/2012/texmf-dist/ls-... 32 Perhaps the pertinent question first: Are there maybe packages that would make me able to write "cleaner" LaTeX code? While some packages exist, this is very user-specific. For example, while you enjoy an interface \int{x,a,b}{f(x)}*, I may enjoy an interface that is slightly more verbose, as in \integral[variable=x,lowerbound=a,upperbound=b]{f(x)}, ... 31 There are no pros of hard-wrapping and no cons of soft-wrapping. It's just habit that makes us hard-wrap, that and not knowing about M-x longline-mode. TeX doesn't care about single newline characters[1], treating them as normal spaces. So as far as the document is concerned, there's no argument for one over the other. But wrapping is useful for us, the ... 29 The answer to your question is two fold: Yes, comments are ignored when compiling and the text of a comment is irrecoverable from the final document. However, no. It is often possible to tell where / how long the comments in the source were. For instance, take the following senario: Line 1 Line 2 vs. Line 1% Line 2 In the compiled output, the newline ... 29 I can give you a couple of tips for packages and tools to start experimenting with, I tried several tools in the past: I like the verbatim and verbatim* environments in TeX. It is an easy and a straighforward way of typesetting a small portion of code right away. However, it cannot wrap lines. I was using the fancyvrb package some time ago, http://ctan.org/... 28 Books about (La)TeX Tout ce que vous avez toujours voulu savoir sur LaTeX sans jamais oser le demander Vincent Lozano's Tout… sur LaTeX is licenced under the licence art libre, typeset using LaTeX. An introduction book in French, clear and whose reading is rather easy. pdf for screen pdf to print sources with figures sources witout figures buy a hardcopy ... 26 The TeXbook is the best place to learn about the underlying TeX language, although TeX-by-Topic (texdoc texbytopic) in most distributions is a good free alternative. But much of what you show is not directly using TeX primitives but using constructs such as \list defined in the latex format. The LaTeX Companion has detail for that or the free documented ... 25 This is only partly true, and only in certain circumstances. Good LaTeX style depends on several things, but normally one tries for three things: 1. portability, 2. logical mark-up and 3. readability/editability. Package use can affect portability, so one should normaly eliminate any that are not absolutely needed. A journal may send back a submission that ... 24 Another answer is that TeX has a fixed maximum size of input lines, that is, if a non-wrapped line exceeds a certain length, there will be an error message. This limit is quite large nowadays. You'll find it in your texmf.cnf: buf_size = 200000 But it used to be smaller in the past, and anyway, who wants to think about something like this while writing ... 23 Under normal circumstances (i.e. not in verbatim or similar), TeX converts line ends to spaces and combines multiple spaces into a single space. It also skips spaces at the start of a line. Thus % Comment to show start of text \usepackage{foo} and % Comment to show start of text \usepackage{foo}% Note spaces are equivalent. In the same way \... 21 It's hard to find them because they don't exist. TeX is written in Pascal (one of the many flavors of it), but the source is interspersed with description of the code in the Web system devised by Knuth and others as part of a "literate programming" project. The commented source is in tex.web (and tex.ch, a supplementary file where adaptations for specific ... 21 I'll use an example from the TeXBook source This manual is intended for people who have never used \TeX\ before, as well as for experienced \TeX\ hackers. In other words, it's supposed to be a panacea that satisfies everybody, at the risk of satisfying nobody. Everything you need to know about \TeX\ is explained here somewhere, and so are a lot of things ... 19 TeXStudio recognises commands that it finds in files ending with .cwl. The \eqref command and the align* environment come from the amsmath package, so you need to make sure that amsmath.cwl is loaded. Under some circumstances, this will happen automatically, but the mechanism isn't foolproof (e.g. it doesn't know that amsmath can be loaded indirectly via \... 19 I'm about to write my master thesis and I want to know these conventions for latex. My goal is to achieve a readable, reusable, easy to modify and standard source code. I am afraid I cannot offer any advice on the "easy to modify" and "standard source code" parts as they are contradicting the very essence of TeX and LaTeX2e. Your question sounds as if ... 18 one simple tactic that will make the body of your input more readable is to always start display material on a new line, and start another new line at the end of the display. break lines within display math so that the input breaks coincide with the line breaks in the output. (i've just spent a couple of hours "de-stringing" run-on input for a book, and my ... 18 I study computer science, therefore my answer is strongly biased. Anyway, it is considered good practice keeping 80 cols as maximum width. The reason is quite funny as well, it is related to the dimension of the punched cards used in the old days. Hard wrapping makes the code nice and tidy, as there are some editors that do not wrap lines when you open a ... 18 I assume you're aware that LaTeX/TeX is not the same as MathJaX. It would certainly be possible to make the ( and ) characters "active" (to use TeX jargon) in math mode so that they automatically generate \left\lparen and \right\rparen, respectively. (Aside: one certainly wouldn't want to do this in text mode.) However, that would be a very poor idea in ... 17 With the package xpatch (or the experimental regexpatch) one can say \xshowcmd\LaTeX and get the answer > \LaTeX =\long macro: ->L\kern -.36em{\sbox \z@ T\vbox to\ht \z@ {\hbox {\check@mathfonts \fontsize \sf@size \z@ \math@fontsfalse \selectfont A}\vss }}\kern -.15em\TeX . The command will also show the meaning of macros defined with \newcommand ... 17 The answers so far (maybe with the exception of Andrew's – dialectical as always) have argued for the pros of hard line breaks. So let me add a somewhat different viewpoint: (1) As a community, we do care a lot about semantical markup: We leave the actual formatting of our document's text to a post-processor (e.g., pdflatex), which does a fairly good job in ... 17 Braces are not just for delimiting arguments. Braces around arguments are generally only necessary if the argument consists of more than one token (according to TeX's rules). So \tilde{\psi} is the same as \tilde\psi, but \textbf psi will only make p bold. One of the goals of LaTeX clearly was to tame TeX's free-wheeling syntax: TeX allows macros to be ... 17 The conversion of two consecutive newlines to a \par token comes from TeX's parser and so all formats of TeX (plain, LaTeX, ConTeXt) observe it too. Note that \par gobbles all whitespace until the next non-whitespace token, so three or more consecutive newlines have the same effect as two: one new paragraph. So if you want to have three blank lines ... 17 You can find out what any command does by asking LaTeX itself. Just open up a console window and run latex (or whatever variant you prefer), and then you can issue commands line by line. For example, to find out what \z@ means, you can use latex **\makeatletter *\show\z@ and LaTeX will give you > \z@=\dimen12. (The \makeatletter command allows you ...

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