Hot answers tagged formatting
17
David did beat me by a couple of minutes, but this version here does indentation as requested and is not producing overfull lines (within reason):
\documentclass{article}
\makeatletter
% this defines myverbatim environment. to change name replace "myverbatim" in all places below (strctly speaing it is only necessary in some but ... :-)
...
14
\documentclass{article}
\begin{document}
\lineskip0pt
\framebox[3cm]{\strut Text1}
\makebox[3cm]{\strut\vrule}
\framebox[3cm]{\strut Text2}
\makebox[3cm]{\strut\vrule}
\framebox[3cm]{\strut Text3}
\end{document}
11
You just want the definition of verbatim without the \obeylines part:
!
\documentclass{article}
\usepackage[T1]{fontenc}
\makeatletter
\newenvironment{exB}{%
\trivlist
\item\relax
\let\do\@makeother \dospecials
\verbatim@font \@noligs
\hyphenchar\font\m@ne
\catcode`\ \active
\catcode`\^^M\active
\catcode`\\\active
\lccode`\~`\\%
...
10
Yes, it's possible, see p. 29 in the manual:
\documentclass{article}
\usepackage{siunitx}
\sisetup{output-exponent-marker=\ensuremath{\mathrm{E}}}
\begin{document}
\num{1e3}
\SI{2.3e5}{m}
\end{document}
9
You need to run this twice
\documentclass{article}
\usepackage{color}
\makeatletter
\def\savepos#1{\leavevmode\pdfsavepos\write\@auxout{%
\gdef\string\save@#1{{\the\pdflastxpos sp }{\the\pdflastypos sp }}}}
\def\xx#1{\expandafter\expandafter\expandafter\@firstoftwo\csname save@#1\endcsname}
...
9
Her's one possibility using the caption package; using the width key you can assign a predefined width (0.8\textwidth in my example):
\documentclass{article}
\usepackage{caption}
\usepackage{lipsum}
\begin{document}
\lipsum[2]
\begin{figure}
\captionsetup{width=0.8\textwidth}
\centering
A Figure
\caption{\protect\lipsum[4]}
\end{figure}
\end{document}
...
8
Normally you would use \, for a thin space $1\,000\,000$ If you are entering that by hand. As noted in the comments siunitx or other packages have the ability to parse the bare number 1000000 and then format it according to formatting parameters with commas or thin spaces, so it depends what you want to do (and where the numbers are generated). Whether it is ...
8
Briefly, there are two options in R, these are "Sweave library" (not my favorite) and "knitr library". After using both, I recommend using knitr.
What do you need?
First, you need install knitr in R,
>install.packages("knitr")
And load it:
>library(knitr)
Then you create a regular \LaTeX file and save it with the extension .Rnw (foo.Rnw)
I ...
7
Here you can specify the width of the boxes (it will be adjusted to fit if too short) and the separation between the boxes.
\documentclass{article}
\usepackage{keyval}
\makeatletter
\define@key{cascading}{width}{\cascading@wd=#1}
\define@key{cascading}{sep}{\def\cascading@sep{#1}}
\newdimen\cascading@wd
\newcommand{\cascadingblocks}[2][]{%
...
7
One possibility using TikZ:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\tikzset{
table/.style={
matrix of nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={rectangle,draw=black,text width=3em,align=center},
text depth=1.25ex,
text height=2.5ex,
nodes in empty cells
},
row ...
7
Using pdfTeX (i.e., use latex or pdflatex to compile) and a transliteration for 'ancient' Greek:
\documentclass[12pt]{article}
\parindent0pt
\useackage[T1]{fontenc}%
\usepackage[utf8]{inputenc}%
\usepackage[polutonikogreek,latin,english]{babel}
% switch to language environments
\newcommand{\latin}[1]{%
\foreignlanguage{latin}{#1}}
...
6
A great deal depends on the amount of customization that you are planning to do; there isn't really a single answer. As Lockstep's canonical answer shows, there are many different sorts of customization which are done in different ways.
In general, it's unusual to start with a "paste" of anything -- at least in the sense of physically cutting and pasting. ...
6
Another option, using TikZ and chains:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains}
\begin{document}
\begin{tikzpicture}[
start chain=going below,
node distance=3mm,
every node/.style={on chain,join},
every join/.style={-},
block/.style={draw, text width=3cm,align=center}
]
\foreach \i in {1,...,5}
\node[block] {Text \i};
...
6
Maybe simply:
\documentclass{article}
\begin{document}
\makeatletter
%\def\verbatim@font{\normalfont\ttfamily} % original one
\def\verbatim@font{\normalfont\sffamily}
\makeatother
\begin{verbatim}
Sans serif,
indeed.
\end{verbatim}
\end{document}
6
The command
\renewcommand\contentsname{\Large{TABLE OF CONTENTS}}
is wrong as the \....name macros are just supposed to have and (expandable) macro with the text to use to allow for localisation. A font command is not expandable so will not work in all contexts. If you were to put in a font command you should keep it local to the command, \Large does not ...
5
Similar as the definition for the tt fontfamily, you can build a sf family to use \sffamily:
\documentclass{article}
\usepackage{fancyvrb}
\makeatletter
\begingroup
\catcode`\`=\active
\gdef\FV@fontfamily@sf{%
\def\FV@FontScanPrep{\FV@MakeActive\`}%
\def\FV@FontFamily{\sffamily\edef`{{\string`}}}}
\endgroup
\makeatother
\begin{document}
\noindent ...
5
Use aligned:
\begin{equation*}
\begin{aligned}
m_{12}(\{ \emph{Red},\emph{Blue} \})
= K' * \bigl[ & m_{1}(\{ \emph{Red},\emph{Blue} \})*m_{2}(\{ \emph{Red},\emph{Blue} \}) \\
+ & m_{1}(\{ \emph{Red},\emph{Blue} \})*m_{2}(\{ \emph{Red},\emph{Blue},\emph{Green} \}) \\
+ & m_{2}(\{ \emph{Red},\emph{Blue} \})*m_{1}(\{ ...
5
Have you tried using the align environment?
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
m_{12}(\{Red,Blue\})&=K'*[m_1 (\{Red,Blue\})*m_2(\{Red,Blue\})\\
&\qquad +m_1(\{Red,Blue\})*m_2(\{Red,Blue,Green\})\\
&\qquad +m_2(\{Red,Blue\})*m_1(\{Red,Blue,Green\})]
...
5
IEEEtran sets up the \section titles in the normal (or standard LaTeX2e) way using \@startsection. The font choice for sections are \normalfont\normalsize\centering\scshape:
\def\section{%
\@startsection{section}% type
{1}% level
{\z@}% indent
{1.5ex plus 1.5ex minus 0.5ex}% top separation before heading
{1sp}% bottom separation after ...
5
Please always post complete small document that shows the problem and allows answers to be tested. The package allows you to go
\SetArgSty{textrm}
to replace the default emph but that affects several components not just if clauses so might be more than you want.
5
You can do this although you don't get the listings formatting inside the alert, but perhaps that's OK for comments..
\documentclass{beamer}
\usepackage{listings}
\begin{document}
\begin{frame}[fragile]{Test}
\begin{lstlisting}[escapeinside=`']
x = z // Assigns the value of y to x.
x = y `\alert<2->{// Assigns the value of y to x.}'
...
5
For example
\documentclass{article}
\usepackage{listings}
\begin{document}
\lstset{moredelim=[is][\itshape]{[}{]}}
\begin{lstlisting}[frame=single]
Array1: 78 54 31 54 92 86 23 54 65
54 54 38 100 92 86 59 54 70
[59 54 91 65 54 31 54 31 54 70
100 91 92 55 70 54 51 61 91
65 59 54 38 54 81 61 92 59 54 38 54 96 61 92]
59 54 38 54 81 54 92 90 54 92 ...
5
The simplest thing to do is to load the verbatim package in your document's preamble; then you can put
\verbatiminput{output.txt}
in your document. This will include the contents of your text file, set it in a typewriter font, and not change the formatting at all.
A more full-featured solution involves loading the listings package, as suggested by Marco ...
5
The class book does not include starred chapters into the table of contents. The \tableofcontents and \listoffigures use a starred chapter internally, therefore I guess that you are using package tocbibind that includes both \tableofcontents and \listoffigures in the table of contents. The first can be disabled by option nottoc:
\documentclass{book}
...
4
The standard way to cope with this kind of problems is to use \@seccntformat, the macro that takes care of formatting the section number (any level below chapter, in the standard classes).
The usual definition is
\csname the#1\endcsname \quad
where #1 is the counter associated to the current section level. So if you define
\def\@seccntformat#1{%
...
4
I wrote a LaTeX template to imitate the features I use most often in Word. The code is below, and here's a blog post I wrote about it, which includes a sample PDF.
\documentclass[12pt]{article}
% Emulate MS Word
\usepackage{wordlike}
% One inch margins
\PassOptionsToPackage{margin=1in}{geometry}
% Remove footnote indentation
...
4
Here's one possibility; the idea is to place a beamercolorbox at the desired fixed location, using TikZ. In every frame that should receive a "take away" box, simply use \insertimptext{<text>}:
\documentclass{beamer}
\usetheme{CambridgeUS}
\usepackage{tikz}
\makeatletter
\newcommand\insertimptext[1]{
\begin{tikzpicture}[remember picture,overlay]
...
4
Not with xlop, but with some labor with expl3 you can do it.
\documentclass{article}
\usepackage{xparse,l3regex}
\ExplSyntaxOn
\NewDocumentCommand{\showmult}{mm}
{
\anna_showmult:nn { #1 } { #2 }
}
\tl_new:N \l__anna_temp_tl
\tl_new:N \l__anna_factora_tl
\tl_new:N \l__anna_factorb_tl
\tl_new:N \l__anna_result_tl
\tl_new:N \l__anna_table_tl
\seq_new:N ...
4
For more automation, you may want to define a new command \bitem, as follows:
\documentclass{article}
\newcommand\bitem[1]{\item{\bfseries #1}\\}
\begin{document}
\begin{enumerate}
\bitem {Specify a mean equation for the returns}
by testing for serial dependence of $r_t$ an, if necessary, building an ARMA model
\bitem {Test for ARCH ...
4
I claim this is a problem with the dvi driver bleeding the coloured panels too far, but I see the same with dvipng You can compensate by over-printing an uncoloured table over the top so the rules are on top of the colour not adjacent.
Compare
and
\documentclass{standalone}
\usepackage[table]{xcolor}
\begin{document}
\def\foo#1{\begin{tabular}{ ...
Only top voted, non community-wiki answers of a minimum length are eligible


