Februar 16th, 2012 by Stefan Kottwitz
On TeX.SX, Primal Pappachan asked:
“How can I introduce a non-technical person to LaTeX?”
There are several answers, for helping learning LaTeX without being too complicated. Yiannis Lazarides gave some of the best suggestions:
- Assist in the TeX installation and install a full distribution, to avoid frustration by installation difficulties later.
- Provide a small template and a compilable document which roughly meets their requirements.
- Assist with the first steps.
- We are used to table of contents, lists and index - a new user though might be impressed how easy that is.
- Explain the concepts of floats early - better show benefits than let a user run into unexpected problems with moving objects.
I would add:
- Point the way to up-to-date LaTeX online resources.
- Show how the mentioned Q&A site TeX.SX works, so he can ask for help or find existing solutions there.
- Introduce him to a LaTeX discussion forum, such as LaTeX-Community.org. A web forum is easy to use and you can talk and discuss, in contrast to a Q&A site. Usenet might be a bit harder to introduce.
- For best online support, explain the importance of code such as minimal working examples.
Visit the original question and answers on the site if you would like to read more.
Category: TeX and LaTeX, TeX.SX, LaTeX General |
1 Comment »
Januar 24th, 2012 by Stefan Kottwitz
Untypical for a Q&A site, there’s currently an exchange of views on TeX.SX:
As an expert, can you always use TeX for (nearly) any kind of document?
“Yes, you can:”
- It’s easy if you are a routine user, you know the common packages.
- Typing a letter, for example, is just like 20 TeX commands added to the text.
- You get the best possible hyphenation and justification, and a professional consistent look - why to abandon it for a “simple” document.
- After some time you’ve got a lot of documents to use as a template or as a start for a similar document.
- Your, let’s say, 16 years old document still work today. Try documents made with a word processor 16 years ago - can you open it today with current software, without layout loss or change?
- TeX users naturally have TeX installed. Some have a dislike for installing a huge wordprocessing software or suite such as Open/LibreOffice or MS Office - this is overkill for simple documents.
“No, you cannot:”
- For typesetting music, TeX may not be the best choice. Though there’s MusiXTeX, Lilipond seems to be favored.
- TeX should not be used for documents intended for quick onscreen use, such as manual pages which should be readable in a text console window. mandoc and Groff are recommended.
There are 16 answers until know. Perhaps you have a new important point to add? See the original answers with further points.
Category: TeX and LaTeX, TeX.SX, LaTeX General |
No Comments »
November 5th, 2011 by Stefan Kottwitz
Redfiloux asked on TeX.SX:
How to decorate a \path?
My question is about drawing a “commutative-type diagram” in mathematics. I would like to integrate an arrow of the type \rightsquigarrow, which is described how to be obtained here: Squiggly arrows in TikZ.
The problem is that I use \path to connect the entries of my matrix in TikZ (because this part comes integrated in a bigger diagram), and I get an error:
“Package PGF Error: I cannot decorate an empty path.”
The code is
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{amssymb}
\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of math nodes, row sep=3em,
column sep=4em, text height=2ex, text depth=0.25ex]
{ U & U \\};
\path [->, font=\scriptsize, line join=round,
decoration={zigzag,segment length=4,
amplitude=.9,post=lineto,post length=2pt},
decorate] (m-1-1) edge node[auto] {F} (m-1-2);
\end{tikzpicture}
\end{document}
where the decorate part does not work.
Answer:
You could specify the decoration to the path, and give the edge the decorate option:
\path [->, decoration={zigzag,segment length=4,amplitude=.9,
post=lineto,post length=2pt},font=\scriptsize,
line join=round] (m-1-1) edge[decorate]
node[auto] {F} (m-1-2);
Category: TikZ |
No Comments »
August 23rd, 2011 by Stefan Kottwitz
Eddy asked on TeX.SX:
How to color the font of a single row in a table?
I have a table and I want to make the font color red for just one row (not the background). How do I do that? Here’s my table:
\begin{tabular}{ l | l l l l }
& 1 & 2 & 3 & 4 \\
\hline
1 & A & B & C & D \\
2 & A & B & C & D \\
3 & A & B & C & D \\
4 & A & B & C & D \\
\end{tabular}
Answer:
You could use the tabu environment of the tabu package with the command \rowfont, for example:
\documentclass{article}
\usepackage{tabu}
\usepackage{xcolor}
\begin{document}
\begin{tabu}{ l | l l l l }
\rowfont{\color{red}}
& 1 & 2 & 3 & 4 \\
\hline
1 & A & B & C & D \\
2 & A & B & C & D \\
3 & A & B & C & D \\
4 & A & B & C & D \\
\end{tabu}
\end{document}
Category: Tables |
No Comments »
Juli 12th, 2011 by Stefan Kottwitz
BrettHarry asked on TeX.SX:
How to merge columns in a table?
I have this table, but wanted to format the first row. I like to match the two columns of first row, and last two columns of the same first row. Any suggestion on how to do that?
\begin{table}[!h]
\caption{Comparison of percentages.}
\begin{tabular}{lclclclclc}
\hline
\hline
Mode & Var & Cum\\
\hline
{} & EF & CHF & EF2 & CHF2\\
1 & 17.5 & 19.1 & 17.5 & 19.1\\
2 & 11.8 & 12.7 & 29.3 & 31.9\\
3 & 6.6 & 5.6 & 35.9 & 37.4\\
\hline
\end{tabular}
\end{table}
Answer:
An example, how it can be done using \multicolum, with some improvements using booktabs:
\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\setlength{\heavyrulewidth}{1.5pt}
\setlength{\abovetopsep}{4pt}
\begin{document}
\begin{table}[!htbp]
\centering
\caption{Comparison of percentages.}
\begin{tabular}{*5c}
\toprule
Mode & \multicolumn{2}{c}{Var} & \multicolumn{2}{c}{Cum}\\
\midrule
{} & EF & CHF & EF2 & CHF2\\
1 & 17.5 & 19.1 & 17.5 & 19.1\\
2 & 11.8 & 12.7 & 29.3 & 31.9\\
3 & 6.6 & 5.6 & 35.9 & 37.4\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Category: Tables |
No Comments »
April 18th, 2011 by Stefan Kottwitz
Alexx Hardt asked on TeX.SX:
How can I draw a diagram for matrix multiplication with LaTeX?
I’m trying to make a PDF manual for matrix multiplication with LaTeX. I’d like to generate a graphic similar to this one (from Wikipedia/Matrix multiplication):
I guess this will be quite a bit of work, but is there another way than using the eepic package? I have read into some examples and the manual, and it seems very complex to generate a graphic like this with that package.
If there is no other way, I’ll have to use eepic, but I hope someone here could point me to a package or another way.
Answer:
I recommend to use TikZ and its matrix library, specifically the matrix of math nodes feature. TikZ offers a great and comprehensive manual.
Have a look at this example and its source code, written by Alain Matthes, in the TikZ example gallery: Matrix multiplication. It deals exactly with your subject.
Category: TikZ |
No Comments »
Dezember 13th, 2010 by Stefan Kottwitz
Martin Tapankov asked on TeX.SX:
What is a good way to make circled numbers in text?
I’m trying to make some good-looking numbers in a circle, using the simple command:
However, the circle is misaligned vertically with the number, and look a bit sloppy:
Any suggestions how can I adjust the vertical alignment so that the numbers look more centered w.r.t to the circles? Or, if that’s not an option, what other ways to achieve the same results are possible?
I will use those only for numbers, and in very few places, so manual adjustment per glyph is an option.
I’m using pdfLaTeX with Computer Modern, if that matters.
Answer:
Here’s a TikZ solution:
\documentclass{article}
\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
\begin{document}
Numbers aligned with the text:
\circled{1} \circled{2} \circled{3} end.
\end{document}
It’s just a node. TikZ options are used to align the base line, to adjust the size and to get the circle shape. You’re free to choose further options regarding size or circle thickness (option thick). There’s more: for example you could even name the nodes by another argument to connect them by arrows later.
If one like to use it for an enumerated list, for example, it’s easy but has to be protected:
\usepackage{enumitem}
...
\begin{enumerate}[label=\protect\circled{\arabic*}]
\item First item
\item Second item
\item Third item
\item Fourth item
\end{enumerate}
Category: TikZ |
No Comments »
Dezember 11th, 2010 by Stefan Kottwitz
Yasser Sobhdel asked on TeX.SX:
Can I have any harpoons in TikZ?
I refer to my previous question on harpoons: “How to draw protocol interaction” using amsmath. The closest thing I have found is this code:
\begin{tikzpicture}[decoration={bent,aspect=.3}]
\node[circle,draw] (A) at (.5,.5) {A};
\node[circle,draw] (B) at (3,1.5) {B};
\draw[->,decorate] (A) -- (B);
\draw[->,decorate] (B) -- (A);
\end{tikzpicture}
Answer:
There are so called partial arrow tips in TikZ. Use for instance left to, right to, left hook or right hook. They are described in section 23.7 of the pfg 2.10 manual (22.6 in the pgf 2.0 manual).
Inserting this into your example:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}
\node[circle,draw] (A) at (.5,.5) {A};
\node[circle,draw] (B) at (3,1.5) {B};
\draw[-left to] (A.north east) -- (B.west);
\draw[-left to] (B) -- (A);
\end{tikzpicture}
\end{document}
Category: TikZ |
No Comments »
Dezember 3rd, 2010 by Stefan Kottwitz
Peter Smit asked on TeX.SX:
Why does fit not scale?
I have a problem with the fit library in TikZ.
When I scale the figure (with the TikZ scale command), the fit box doesn’t!
Why is that? Could I somehow change it?
Example:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit}
\begin{document}
\begin{tikzpicture}[state/.style={circle,draw,thick,
loop above,inner sep=0,minimum width=10}]
\node[state] (a) at (0,1) {} edge [loop above, thick]
coordinate (al) ();
\node[state] (b) at (1,1) {} edge [loop above, thick]
coordinate (bl) ();
\node[draw,rectangle,fit=(a) (b) (al) (bl)] {};
\end{tikzpicture}
\begin{tikzpicture}[scale=2,state/.style={circle,draw,thick,
loop above,inner sep=0,minimum width=10}]
\node[state] (a) at (0,1) {} edge [loop above, thick]
coordinate (al) ();
\node[state] (b) at (1,1) {} edge [loop above, thick]
coordinate (bl) ();
\node[draw,rectangle,fit=(a) (b) (al) (bl)] {};
\end{tikzpicture}
\end{document}
Answer:
Add the option transform shape to scale also the box resp. shapes:
\begin{tikzpicture}[scale=2,transform shape,
state/.style={circle,draw,thick,loop above,inner sep=0,
minimum width=10}]
Output:
Category: TikZ |
No Comments »
August 26th, 2010 by Stefan Kottwitz
Peter Smit asked on TeX.SX:
How to make a three level deep tree with TikZ?
I am busy making a full binary tree of three levels deep.
The code I am having now is (using the trees library):
\begin{tikzpicture}
\node {root}
child {node {left}
child {node {lleft}}
child {node {rleft}}
}
child {node {right}
child {node {lright}}
child {node {rright}}
};
\end{tikzpicture}
The problem is that rleft and right are printed over each other.
Preferably I would like TikZ to figure this out by itself, for example if I give a minimum distance between nodes on the same level. Is this possible? (My final nodes will not have text but will be fixed size shapes)
Off course it can be that the solution is: “Don’t use ‘trees’”. In that case, what is the best way to do this?
Answer:
You could specify options for each level, for instance silbling distance but also level distance.
Example:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[level distance=1.5cm,
level 1/.style={sibling distance=3cm},
level 2/.style={sibling distance=1.5cm}]
\node {root}
child {node {left}
child {node {lleft}}
child {node {rleft}}
}
child {node {right}
child {node {lright}}
child {node {rright}}
};
\end{tikzpicture}
\end{document}
Category: TikZ |
No Comments »