-1

Feel free to share the most useful things you have done in LaTeX.

Whether it's newcommands, tricks, macros, snippets, keyboard shortcuts, or anything you've used and thought, "geez, if only I had done this earlier... I should share this somewhere."

Share and describe it, and please don't repeat answers.

4
  • 4
    Welcome! But I'm not sure whether this post could end up to be a famous question or just be closed for NOT focused. It's also hard to define "most useful thing", pls check what TeX.SX's role(tex.meta.stackexchange.com/questions/1436/welcome-to-tex-sx). I don't think this site is somewhere to just share the code. Actually, each post need to oriented with a concrete theme, while "most useful thing" seemed not a good one.
    – Explorer
    Commented Jul 16 at 3:09
  • A library of handy code is a good idea, but perhaps this page should just be links. I have a 2k line linguistics macro (plus 3.5k line input file) - it won't fit here. Plus a hieroglyphs transliteration macro too big for an answer box. Etc. Plus 2: after a certain number (500?) an index or toc will be needed to find something easily.
    – Cicada
    Commented Jul 16 at 6:44
  • 2
    sorry this does not match the site format which should ask specific questions that can have specific objective answers Commented Jul 16 at 7:39
  • 1
    I voted to close as lacking focus but duplicate of tex.stackexchange.com/questions/19746/cunning-latex-tricks perhaps Commented Jul 16 at 7:44

1 Answer 1

1

I go first :)

The degree symbol. (can be used in non-math ambient)

\newcommand{\degr}[0]{\ensuremath{^\circ}} 

Like commenting a code section, but on the compiled text, for “less important” parts - requires xcolor package

\definecolor{codegreen}{rgb}{0.333,0.4,0.25}
\newcommand{\ccom}[1]{{\color{codegreen} #1}} % use like \mb{content}

Shorter version of \textcolor{} - requires xcolor package

\newcommand{\gr}[1]{\textcolor{green}{#1}} 

For the mechanic students, signal convention for mechanics/statics on latex (still not the best, but may be helpful) - requires tikz package

\renewcommand{\smallsum}{% small version of sum (upper case sigma) symbol
    \mathop{\textstyle\sum}
}

\newcommand{\moment}{ % counterclockwise positive
    \mathrel{\begin{tikzpicture}[]
        \node at (0,0cm) {$+$}; % Ajusting vertical position of "+"
        \draw[->] (0.15,-0.2) arc (-90:90:0.2cm);
    \end{tikzpicture}}%
}

\newcommand{\vforce}{ % positive for up pointing forces
    \begin{tikzpicture}[]
        \node {$+$};
        \draw[->] (0.2,-0.2) -- (0.2,0.2);
    \end{tikzpicture}
}

\newcommand{\hforce}{ % positive for right pointing forces
    \begin{tikzpicture}[]
        \node {$+$};
        \draw[->] (-0.2,-0.2) -- (0.2,-0.2);
    \end{tikzpicture}
}

signal convention latex statics

Shorter version of mathbf, I use overleaf, so I can't custom the shortcuts.

\newcommand{\mb}[1]{\mathbf{#1}} % use like \mb{content} (im lazy)
4
  • 3
    pls use markdown code snippets(see my edit....). And always post complete code (start with \documentclass and end with \end{document}), it seemed that you are playing with tikz to define symbol, pls also post the result's screenshot.
    – Explorer
    Commented Jul 16 at 3:02
  • Instead of obfuscating your code with shorter versions of established commands, better use an editor with good code completion and/or short cuts. This way people other than you will also be able to read your code comfortably. Commented Jul 16 at 7:49
  • 1
    thanks for sharing this, but why not use \textdegree for a degree symbol? that way it will match your font (hopefully) and be scaled appropriately. (and \textcelsius if this is a temperature on the celsius scale.) there are better ways of writing the arrow-based symbols than tikzpictures, too.
    – cfr
    Commented Jul 16 at 11:16
  • At present you can type 37 °C as is, even using pdflatex and the default font. Note that is not the ordinal ° nor the same that \circ but the true degree symbol. The right shortcut to type it depend on sus keyboard, OS, and even the editor, but worth to learn that and avoid macros in the middle of text for a simple and common symbol.
    – Fran
    Commented Jul 16 at 15:31

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.