Visualizzazione post con etichetta LaTeX. Mostra tutti i post
Visualizzazione post con etichetta LaTeX. Mostra tutti i post

sabato 18 settembre 2010

Interesting LaTeX packages

blowup: something like make your pages bigger
fourier: tu use a new set of font
numname: translates 1 => one
notes: to emphasizes part of text with a box and a margin figure
--
pdftricks: allows the usage of macros which cannot be used (directly) with pdfTeX (e.g. PSTricks)

martedì 2 marzo 2010

LaTeX: addcontentsline e hyperref

Tutte le volte che si usa \addcontentsline con hyperref, bisogna scrivere \phantmsection subito prima di \addcontentsline, pena link e segnalibri sballati.

sabato 7 novembre 2009

Sent to... pdfLaTeX (Vista)

Ho scritto un mini-script batch per Windows che esegue pdfLaTeX su un file cliccandovi sopra con il tasto destro del mouse e selezionando Send to.

Questo è lo script:
@echo off
FOR %%A IN (%*) DO (
pdflatex -interaction=nonstopmode %%A
echo.
echo pdfLaTeX eseguito su %%A
pause
)


Va salvato con il nome pdfLaTeX.bat e (per Windows Vista) messo nella cartella:
C:\Users\[UserName]\AppData\Roaming\Microsoft\Windows\SendTo\

Riferimenti:
http://blogs.ugidotnet.org/marcom/archive/2007/01/10/65903.aspx
http://www.guit.sssup.it/phpbb/viewtopic.php?t=5295
http://www.guit.sssup.it/phpbb/viewtopic.php?t=5761
http://it.wikipedia.org/wiki/Lista_di_comandi_di_MS-DOS
http://ss64.com/nt/echo.html

lunedì 12 ottobre 2009

LaTeX: installing editor & pdf viewer

Once you've installed TeXLive on your Windws Vista PC, the game is not over, yet.
In fact, LaTeX itself is the "engine" (the compiler), but to produce and see/print your documents you will need*:
- a specific LaTeX Editor;
- a (specific) PDF viewer.

*Please Note: actually, you don't need a specific LaTeX editor; in fact, you can type your LaTeX document wherever you want (i.e. Notepad) and save them with *.tex extension (not *.txt). Nonetheless, a specific editor would help you in a such numerous things... so... Why not?

I'll describe you TeXnicCenter editor and SumatraPDF-TeX viewer.


TeXnicCenter is an Open Source editor, really customizable, available for download at http://www.texniccenter.org/.
The installation process is a Windows standard one (you just have to run a exe file).
The first time you run TeXnicCenter, the software will ask you about your LaTeX distribution path, your default viewer path, etc.
You'll early learn using TeXnicCenter. Just a couple of tips and tricks.

First of all, the spelling.
TeXnicCenter can spell your documents in real time - if you give him a dictionary (language_DIALECT.dic and language_DIALECT.aff). To do this, click Tools - Options - Spelling, in Default Language select a dictionary and a dialect, in Personal Dictionary field type the path of your dictionaries folder. Clicking Download Dictionaries (and being connected to internet), an OpenOffice wiki services web pages with links to all dictionaries available will open - just download the *.zip file and uncompress the two previously cited files in the appropriate folder).
For Italian people, download "Italian dictionary (dizionario italiano)" in Spelling submenu, unzip it_IT.dic and it_IT.aff.

One more interesting thing; auto-completation.
While typing your LaTeX document in TeXnicCenter, you'll se a small yellow tips window appear every time you're typing a LaTeX command that TeXnicCenter recognize - just press ctrl + space to accept the suggestion. May be you want to edit / customize the autocompletation: see here (in Italian only).

With the third tip, we'll get inside the second argument of this post: a pdf viewer.
Every Windows user feels comfortable with Acrobat Reader - and that's OK. But, others pdf viewer are more suitable while your document preparation is a WIP. This means: you can get forward and inverse search from the output pdf and the source tex file.

Quoting http://william.famille-blum.org/
SumatraPDF is a PDF reader which supports two synchronization technologies: pdfsync and the more recent SyncTeX. To use the first one you just need to load the 'pdfsync' package in your latex document as follows: \usepackage{pdfsync} When compiling your source file, LaTeX will generate a .pdfsync file along with the .pdf output file. This file can then be used by SumatraPDF to perform synchronization. With SyncTeX it is not necessary to load any package. However you need to specify the 'synctex' switch when compiling your document with pdflatex: pdflatex -synctex=-1 document.tex Also make sure you have updated your TeX installation as only recent releases of pdftex support this feature (TeXLive 2008 and MikTex 2.7).

We'll talk about SyncTeX.
Quoting again:
SyncTex is directly integrated in pdftex. This has many benefits: there is no need to load a special package in your .tex document, there is no more incompatibilities with latex packages, and the synchronization is more precise. One disadvantage is that the generated synchronization file can be huge, and for that reason it has an option to zip it. One disadvantage is that the generated synchronization file can be huge, and for that reason it has an option to zip it.

So, download SumatraPDF-tex.exe from this page: http://william.famille-blum.org/software/sumatra/index.html
The file you download is the executable files yet (no installation required): move the file (for i.e.) in C:\Program Files\SumatraPDF\ and everytihing is done.

OK, now. Having installed TeXLive 2008 (or MikTeX 2.7 and followers), you won't need anything but compiling with the option -synctex=-1*, so:
pdflatex -synctex=-1 test.tex

*Please Note: -synctex=1 will produce the zipped version of synctex file.

Let's go back to TeXnicCenter: select Build - Definse Output profiles... and set in (La)TeX tab the field as follows (eventually in a new profile copied from LaTeX -> PDF):



Again in Viewer tab:



I quote one more time for the textual part to copy - paste:
1- Menu 'Build\Define output profiles...'
2- Select the profile "Latex=>PDF"
3- Select the tab '(La)TeX'
4- In the field 'Command line arguments to pass to the compiler' add -synctex=-1.

Forward search
To setup forward-search with TeXnicCenter proceed as follows:
1- Menu 'Build\Define output profiles...'
2- Select the profile "Latex=>PDF"
3- Select the tab 'Viewer'
4- Fill the options as follows:
Path of executable: c:\tools\SumatraPDF-sync.exe -reuse-instance
Forward search: select DDE command
Command: [ForwardSearch("%bm.pdf","%Wc",%l,0,0,0)]
Server: SUMATRA
Topic: control
View project's output: select DDE command
Command: [Open("%bm.pdf",0,1,1)]
Server: SUMATRA
Topic: control
Close document before running (La)TeX: Do not close

OK, we're near at the end - we only have to set up the inverse search.
Now just open SumatraPDF, click con Sttings - Options and in the field "Set inverse search command line" the string to start TeXnicCenter is:
"C:\Program Files\TeXnicCenter\TEXCNTR.EXE" /ddecmd "[goto('%f', '%l')]"

Done!

sabato 10 ottobre 2009

How to install TexLive 2008 on Windows Vista Home Premium

Probably, Windows user will feel more comfortable with MikTeX, but I prefer TeX Live, and the following is:

How to install TexLive 2008 on Windows Vista Home Premium

The official web page of TeX Live 2008 is:
http://www.tug.org/texlive/

There, you can find whatever you need about TeX Live 2008 (including the TeX Live 2009 pretesting - update: today, Saturday 10th October 2009).

I'll try to give you the briefest instruction to install the distribution in Windows Vista using text mode - it is really easy!

First of all, download the zip file install-tl.zip from this website:
http://www.tug.org/texlive/acquire.html
and unzip the archive wherever you like.

Than click Start - Run and enter cmd: this will open the command line (don't be worried, everything is ok!).

Digit:
cd (unzippedfolderpath)
where (unzippedfolderpath) is the path of the folder where install-tl.bat is.

Now, if you type
install-tl -help
you can read the help screen, with a complete listing of the options available.

In particular, simply digiting install-tl the installer will run with all default option and with the graphical user interface (GUI). For each option you want to specify, the syntax, as always, is -optionname (optionargument), where (optionargument) can not be defined for some options.

In this how to, we'll use two options. The first one is -no-gui (which does not requires any option argument), and runs the installer in text mode. The second one is -location (url): if you don't specifies this option, the installer will download all file (more than 1800 file for almost 1.5GB) from the nearest official mirror from where you are. In Italy, the official mirror is ftp.uniroma2.it, but the bit-rate in download is really astonishing. So, from (the north of) Italy you can choose, for example, http://bo.mirror.garr.it/mirrors/CTAN/systems/texlive/tlnet/2008/
Actually, you will enter
install-tl -no-gui -location http://bo.mirror.garr.it/mirrors/CTAN/systems/texlive/tlnet/2008/
* UPDATE: sometimes bologna mirror doesn't work; you can use ftp://mirror.switch.ch/mirror/tex/systems/texlive/tlnet/ instead. *
There are other two option I'd like to talk about: -non-admin allows you to install Tex Live 2008 only for current user (with windows Vista); the second, if you need download files through a proxy, please look at this page: http://www.gnu.org/software/wget/manual/html_node/Proxies.html.

At this point, you will see a window like this one.


A (small) problem occurs: even if running the installer as a Windows Vista administrator, install-tl can't write inside Program files\ folder. So, you will create another texlive folder (in this example c:\tl2008\) and digit D and again change the TEXDIR with the your new path. Then, you can return to the previous menu and all TXMF folder - but TEXMFHOME - will install inside the specify directory.

OK, if you don't want to change any other option, you can now digit I and wait (also for a long time, depending to your internet connection speed - the whole installation took me almost 3 hours). The installation process ends with a message which informs you of a install-tl.log file stored inside the TeX Live main folder. A this point, inside Start menu a new folder texlive will be present.

Congratulations! TeX Live 2008 is now ready to run in your Windows Vista PC!

Oh, just the last thing: TeX Live 2008 takes care to install a *.ps viewer (PS_View) and a *.dvi viewer (DVIOUT). You will probably look for a *.pdf and, obviously, a LaTeX specific editor.

lunedì 28 settembre 2009

Figures and margins in classicthesis

If you're writing with classicthesis (as in this post - two side option active), a big white margin is left on the external sides of the pages (right margin for odd pages, left margin for even pages). This is due to the complex mechanism that rules classicthesis settings of the pages. But... even if you accept these settings, also because you think they're beautiful, maybe you want some more width for your (sub)figure, without destroying all classicthesis' work.
So, you can consider the following solution (packages required: graphicx, calc):

\newlength\largefigure % to create a new length
\setlength{\largefigure}{\columnwidth+\marginparsep+%
\marginparwidth} %%% to set largefigure as the sum of the
%%% width of the text, of the width of the margin note and
%%% of the width of the white spaces between the thext and
%%% the margin note.
%%
\begin{figure}%
\centering%
\makebox[\textwidth][r]{% %%% you make a box which width is
%%% not important for the contents of the box itself
%%% (\textwidth) and which will flush [r] from the right
%%% ([l] from the left) margin of the text; whatever doesn't
%%% find place in the box will exceed in the opposite side.
%%% Please note that a curly brace is still open.
\includegraphics[width=.8\largefigure]{figurename} %%% you
%%% can now include your graphic with the usual option for
%%% \includegrephics
} %%% Here you "close the box"
\caption{This is the caption\dots}%
\label{fig:label}%
\end{figure}


In this case, you can't see anything special but the absence of the overfull hbox message in your log file, even if your figure is larger than the standard textwidth and, more important, if your figure is on odd page, it would flush left.

This trick is more useful while including subfigure on the same line (subfig package required), because if the total horizontal amount of the figures is wider of the textwidht, LaTeX put the second one in a new row and you can't use the white external margin:

\newlength\largefigure %%% as above
\setlength{\largefigure}{\columnwidth+\marginparsep+%
\marginparwidth} %%% as above
%%
\begin{figure}%
\centering%
\makebox[\textwidth][l]{% %%% as above; this time, the
%%% figures flushes from the left
\subfloat[Sunfigure (a) caption.\label{fig:sfalabel}]%
{\includegraphics[width=.48\largefigure]{figurename}}%
\hfill%
\subfloat[Subfigure (b) caption.\label{fig:sgblabel}]%
{\includegraphics[width=.48\largefigure]{figurename}}%
}
\caption{Figure's caption.}%
\label{fig:figlabel}%
\end{figure}


And now... What if you want to insert in the figure environment not a single or multiple \includegraphics element, but something else? For example, a tikz picture contented in an external file? How can you warranty the width of the picture?


\begin{figure}
\centering
\subfloat[A big tikz picture.\label{fig:one}]{%
\makebox[\textwidth][l]{% %%% as above
\resizebox{.45\largefigure}{!}{%
\input{fig/tikzfile}}}}%
\hfill%
\subfloat[Another big tikz picture.\label{fig:two}]{%
\makebox[\textwidth][l]{% %%% as above
\resizebox{.45\largefigure}{!}{%
\input{fig/tikzfile}}}}%
\caption{Two tikz pictures}
\label{fig:label}
\end{figure}


Please note: the hint for this post come from this thread on guit forum.

mercoledì 23 settembre 2009

Ambiente Tabbing: le tabulazioni


\documentclass{article}

\begin{document}
\begin{tabbing}
If \= it’s raining \\
\> then \= put on boots, \\
\> \> take hat; \\
\> else \> smile. \\
Leave house.
\end{tabbing}
\end{document}

sabato 19 settembre 2009

Placeins: figure prima della sezione successiva.

Per forzare lo "svuotamento" della coda delle figure e tabelle prima dell'inizio della sezione successiva, si usa il pacchetto placeins con l'opzione section.

endfloats, invece, sposta gli oggetti flottanti a fine documento.

sabato 12 settembre 2009

TeX Live 2008 su MS Windows XP: albero locale et al.

L'albero locale si trova al percorso:
C:\Programmi\texlive\texmf-local\tex\latex\local


Nella cartella:
C:\ProgramS\texlive\2008\texmf-doc\doc
è pieno di guide.

Infine,
http://bo.mirror.garr.it/mirrors/CTAN/systems/texlive/tlnet/2008/
sembra essere un buon mirror italiano

martedì 8 settembre 2009

ClassicThesis + Arsclassica: template per relazioni

Io userò lo stile ClassicThesis abbinato al pacchetto ArsClassica per comporre le mie relazioni, come segue.
(Gli altri pacchetti da caricare sono [anche] qui).

\documentclass[twoside,headinclude,%
footinclude,fleqn,%
captions=tableheading]{scrartcl}

\usepackage[nochapters]%
{classicthesis-ldpkg}
\usepackage[nochapters,subfig,%
eulermath,pdfspacing,%
beramono]{classicthesis}
\usepackage[italian]{arsclassica}

\usepackage{lipsum}

\author{Nome Cognome\\{\small 123456}}
\title{{\normalsize Corso}\\[2ex] Relazione di}
\date{A.A. 2008 - 2009}

\pagestyle{useheadings}

\begin{document}
\maketitle


\end{document}

giovedì 4 giugno 2009

TikZ/PGF: qualcosa che assomiglia a una griglia

Nel preambolo:
\def\z{5}
\def\s{.5}
\def\griglia{%
\draw[style=help lines,step=\s] (0,0) grid +(\z,\z);
\foreach \x in {0, \s, ..., \z} \draw (\x, 0) node[font=\tiny, anchor=north, gray] {\x} (0, \x) node[font=\tiny, anchor=east,gray] {\x};}%
}
dove il numero in \z{.} è la dimensione della griglia e quello in \s{.} è la dimensione dello step di griglia.

Si usa così:
\begin{tikzpicture}
\griglia
\end{tikzpicture}
ottenendo



Sviluppi futuri:
  • miglioramento nella definizione di macro;
  • colore del font dei numeri uguale al colore della griglia;
  • scrittura delle coordinate della griglia meno fitta se step inferiore a un certo numero;
  • varie ed eventuali...

domenica 31 maggio 2009

LaTeX: pacchetto showkeys

Il pacchetto showkeys visualizza nel documento compilato le etichette assegnate tramite \label e quelle richiamate con \ref - molto utile quando si stia preparando un documento
con molti riferimenti incrociati.

L'opzione color carica il pacchetto color e colora etichette (assegnate e richiamate) di grigio chiaro; per modificare il colore (nell'esempio, in rosso):
\definecolor{labelkey}{rgb}{1,0,0}
e
\definecolor{refkey}{rgb}{1,0,0}

mercoledì 27 maggio 2009

Latex: disegnare le convenzioni di segno con Tikz

Il seguente codice genera una figura attraverso il pacchetto tikz che rappresenta le convenzioni di segno per un sistema meccanico:



\documentclass{minimal}

\usepackage{tikz}

\usetikzlibrary{%
decorations.pathmorphing%
}

\begin{document}

\begin{tikzpicture}[%
molla/.style={decorate,decoration={snake,post length=5,amplitude=5,pre length=5,segment length=5}, thick},
thick%
]
\draw[<->] (0,1) |- (1,0);
\draw (45:0.6) node {$+$};
\draw[->] (10:1) arc (10:80:1);
\draw[molla,<->] (-0.5,-1) -- node[above=0.2cm] {$+$} (1.5,-1);
\end{tikzpicture}

\end{document}

LaTeX: personalizzare \maketitle

Per personalizzare il risultato di \maketitle, mettere nel preambolo*:
\makeatletter
\def\@maketitle{\begingroup\fboxsep=1.5em
\let\footnote\thanks
\fbox{\begin{tabular}{c}
\LARGE \@title\\[1.5em]
\large\lineskip.5em
\begin{tabular}[t]{c}%
\@author
\end{tabular}\\[1em]
\large\@date
\end{tabular}}\endgroup}
\makeatother

* in questo esempio, si mette una cornice intorno a tutto il contenuto generato da \maketitle.

martedì 28 aprile 2009

LaTeX: Ricominciare la numerazione di...

La numerazione dei capitoli non riprende da 1 all'inizio di una nuova parte, così come la numerazione delle sezioni non riprende da 1 sino all'inizio di un nuovo capitolo.
Ciò significa che, suddividendo un articolo (che non "conosce" i capitoli) in part, le sezioni manterranno la numerazione progressiva indipendentemente dal cambio di sezione (così come fanno i capitoli nella classe book al cambiare della parte).

Scorciatoia:
\makeatletter
\@addtoreset{section}{part}
\makeatother
messo nel preambolo impone a LaTeX di resettare la numerazione delle sezioni a partire da 1 all'inizio di ogni nuova part.

Per variazioni sul tema, giocare con part, chapter, section, ...

Configurazione standard TeXnicCenter

domenica 19 aprile 2009

Customizing TeXnicCenter

Per modificare le auto-completion di TeXnicCenter,
trovare la cartella di installazione del programma, aprire
packages
e trascinare in un editor il file
TeX.xml

Lì sono listati tutti i completamenti automatici del programma.

Nota bene:
in un comando, "a capo" si ottiene con la sequenza
& # x A ;
senza spazi intermedi.

martedì 14 aprile 2009

LaTeX: riproporre una formula con numerazione originale

In LaTeX, se è necessario riproporre una formula già utilizzata (ed etichettata, ad esempio con "eq:ripetuta"), basta usare il seguente:
\begin{equation*}
a=b, \tag{\ref{eq:ripetuta}}
\end{equation*}

giovedì 2 aprile 2009

LaTeX al Politecnico di Milano

"L’associazione “I PoliTEXnici” invita tutti gli studenti di ingegneria meccanica al workshop “LaTeX per l’ingegnere” il giorno 8 aprile nel quale verrano illustrate le principali funzionalità del programma con particolare attenzione alle esigenze ingegneristiche (tabelle, formule, disegno e grafica).
Per assicurarsi il materiale didattico è richiesta l’iscrizione all’indirizzo e-mail: politexnici@gmail.com.

I PoliTEXnici"

Area files: qui

mercoledì 18 marzo 2009

Google

in tutto il web in 16marzo
Per scrivere con caratteri a spaziatura fissa
  questo è il codice 
And what about this one?