LaTeX: indent from second line

Depending on why you want to do this, you might be better off using the built-in TeX support for hanging indentation, which the hanging package sugars. If it’s a one-off, use the package, but if it’s built in to some other layout, the package might just confuse things. Up to you. The \hangindent dimension gives … Read more

Latex: Listings with monospace fonts

The problem is the columns=flexible option. Remove it and it looks like you want it to look. At least, if there is no actual reason for you to use it. If there is, there is no way to have the monospaceness of your snippet to look like in Xcode :).

LaTeX \newcommand default argument: is empty?

Try the following test: \documentclass{article} \usepackage{xifthen}% provides \isempty test \newcommand{\optarg}[1][]{% \ifthenelse{\isempty{#1}}% {}% if #1 is empty {(((#1)))}% if #1 is not empty } \begin{document} Testing \verb|\optarg|: \optarg% prints nothing Testing \verb|\optarg[]|: \optarg[]% prints nothing Testing \verb|\optarg[test]|: \optarg[test]% prints (((test))) \end{document} The xifthen package provides the \ifthenelse construct and the \isempty test. Another option is to … Read more

Correct way to define macros \etc \ie in latex

Earlier I used macros for “et al.”, etc., but nowadays I would discourage people from defining that kind of macros. One problem is what you already observed: it’s surprisingly tricky to get the definitions right so that they handle all special cases correctly (including the interactions with other packages – e.g., those that re-define the … Read more

LaTeX multiple equation references in one

This is a simple solution that requires no additional packages, just one additional label: \begin{subequations} \label{eq1} \begin{align} a & = b \label{eq11} \\ c & = d \label{eq12} \end{align} \end{subequations} And when you do \eqref{eq1} it will display as (1).