LaTeX: Difference between revisions
No edit summary |
|||
| (15 intermediate revisions by the same user not shown) | |||
| Line 9: | Line 9: | ||
** It is only partially supported outside of pdflatex; LuaTex supports it better than XeTeX as of 2023-10 (see the table in the documentation, page 6). | ** It is only partially supported outside of pdflatex; LuaTex supports it better than XeTeX as of 2023-10 (see the table in the documentation, page 6). | ||
* Use the [https://ctan.org/pkg/realscripts realscripts] package for most documents. It improves sub- and superscripts when using OpenType fonts with appropriate features (normally the glyphs are simply drawn at a smaller size). It doesn't work well in certain environments or in certain cases, in which case use a '*' suffix to revert to the previous definitions. It's best to use this from the beginning of a document so that you check each placement. | * Use the [https://ctan.org/pkg/realscripts realscripts] package for most documents. It improves sub- and superscripts when using OpenType fonts with appropriate features (normally the glyphs are simply drawn at a smaller size). It doesn't work well in certain environments or in certain cases, in which case use a '*' suffix to revert to the previous definitions. It's best to use this from the beginning of a document so that you check each placement. | ||
** As of late 2023, it does not work well with [https://ctan.org/pkg/siunitx?lang=en siunitx] in my experience. | ** As of late 2023, it does not work well with [https://ctan.org/pkg/siunitx?lang=en siunitx] in my experience. You'll want to define <tt>text-subscript-command</tt> and <tt>text-superscript-command</tt> to be commands which use <tt>\textsuperscript*</tt> etc., though this does seem to work. | ||
* 72.27 points equals 1 inch equals 25.4 millimeter | |||
* Invoke with <tt>-halt-on-error</tt> for better life quality | |||
** You probably want <tt>-shell-escape</tt> as well. I've never found a situation where it's bad. | |||
===LuaLaTeX/XeTeX notes=== | |||
* LuaLaTeX needs the Harfbuzz renderer to handle complex languages, and it's superior in any case. | |||
** I think this is the default as of 2020 ("LuaHBTex") | |||
==Punctuation== | ==Punctuation== | ||
===Quotation Marks=== | ===Quotation Marks=== | ||
Use <tt>``</tt> for the left mark, and two apostrophes for the right. | * Use <tt>``</tt> for the left mark, and two apostrophes for the right. | ||
* If you're nesting single quotes within double quotes (e.g. for a quote within a quote), you might run into problems when the interior quote ends or begins with the exterior one, e.g. <nowiki>'''</nowiki> (which is rendered as a double right quote followed by a single right quote). To properly nest, use e.g. <nowiki>'\thinspace''</nowiki>. | |||
If you want an actual old-skool quotation mark (for emulating old terminals, perhaps), try <tt>\textquotedbl</tt>. | * If you want an actual old-skool quotation mark (for emulating old terminals, perhaps), try <tt>\textquotedbl</tt>. | ||
** For an old-skool apostrophe, <tt>\textquotesingle</tt>. | |||
===Hyphens/Dashes=== | ===Hyphens/Dashes=== | ||
*Hyphens separate the parts of a compound word. Use a single '-', without spaces. | * Hyphens separate the parts of a compound word. Use a single '-', without spaces. | ||
*En dashes separate the bounds of a range, usually numerics. Use two '-' characters, without spaces. | * En dashes separate the bounds of a range, usually numerics. Use two '-' characters, without spaces. | ||
*Em dashes separate distinct thoughts. Use three '-' characters, without spaces. | * Em dashes separate distinct thoughts. Use three '-' characters, without spaces. | ||
*Minus signs are a mathematical entity. Use a single '-' in math mode. | * Minus signs are a mathematical entity. Use a single '-' in math mode. | ||
* To get two actual hyphens, try <tt>-{}-</tt>. | |||
===Periods=== | ===Periods=== | ||
| Line 36: | Line 46: | ||
===Backslashes=== | ===Backslashes=== | ||
Use <tt>\textbackslash{}</tt> to render a backslash in text. | Use <tt>\textbackslash{}</tt> to render a backslash in text. | ||
==Lists== | ==Lists== | ||
Enclose bulleted lists within a <tt>\begin{itemize}</tt> and <tt>\end{itemize}</tt> block. Each element is preceded by <tt>\item</tt>. | Enclose bulleted lists within a <tt>\begin{itemize}</tt> and <tt>\end{itemize}</tt> block. Each element is preceded by <tt>\item</tt>. | ||
| Line 48: | Line 59: | ||
* Italics: <tt>\textit{italicized text}</tt> (it is advised to end most italicized sequences with "\/") | * Italics: <tt>\textit{italicized text}</tt> (it is advised to end most italicized sequences with "\/") | ||
* Monospace: <tt>\texttt{typewriter-stylized text}</tt> | * Monospace: <tt>\texttt{typewriter-stylized text}</tt> | ||
LuaTeX and XeTeX support modern (TTF, OTF, etc.) fonts naturally. Use <tt>-otf</tt> versions of packages with these engines if they're available (e.g. [https://ctan.org/pkg/kpfonts-otf?lang=en kpfonts-otf] rather than kpfonts). | |||
===Spacing=== | ===Spacing=== | ||
* The default margins are generally 1.5" or more, more suitable for books than other documents. For 1" margins, add <tt>\usepackage{fullpage}</tt>. | * The default margins are generally 1.5" or more, more suitable for books than other documents. For 1" margins, add <tt>\usepackage{fullpage}</tt>. | ||
| Line 56: | Line 70: | ||
To include monospaced documents (code, emails, etc) use <tt>\VerbatimInput</tt> on a filename argument. This requires the <tt>moreverb</tt> package. | To include monospaced documents (code, emails, etc) use <tt>\VerbatimInput</tt> on a filename argument. This requires the <tt>moreverb</tt> package. | ||
* Important attributes include ''fontsize'', ''frame'', ''framerule'', ''label'', and ''numbers'' | * Important attributes include ''fontsize'', ''frame'', ''framerule'', ''label'', and ''numbers'' | ||
To do a background color/image with text, to set a block of text away from the main body, to do anything funky like that, [https://ctan.org/pkg/tcolorbox?lang=en tcolorbox] is the way. For instance, to stretch an image semitransparently behind text without any extra whitespace or background color: | |||
<pre> | |||
\begin{tcolorbox}[enhanced, | |||
size=minimal, | |||
interior style={fill overzoom image=IMAGEFILE,fill image opacity=0.25}, | |||
opacityback=0, | |||
beforeafter skip=0pt] | |||
...text goes here... | |||
\end{tcolorbox} | |||
</pre> | |||
==[[Unicode]]== | ==[[Unicode]]== | ||
Basic LaTeX doesn't support UTF-8 beyond expanding macros based on lexical sequences. If this is intended, use the <tt>utf8</tt> parameter to the <tt>inputenc</tt> package. | Basic LaTeX doesn't support UTF-8 beyond expanding macros based on lexical sequences. If this is intended, use the <tt>utf8</tt> parameter to the <tt>inputenc</tt> package. | ||
You should just use XeTeX or LuaTeX. Both aim to be a fully Unicode-aware TeX engines. You shouldn't need to specify any utf8-specific stuff in your preamble. | |||
==BibTeX== | ==BibTeX== | ||
* Style [http://www.cs.stir.ac.uk/~kjt/software/latex/showbst.html examples] | * Style [http://www.cs.stir.ac.uk/~kjt/software/latex/showbst.html examples] | ||