Redimensionar Tablas en LaTeX

Como se menciono anteriormente al realizar tablas en LaTeX es necesario vigilar manualmente el grosor de la tabla para evitar que la tabla sea mas ancha que la pagina y se "corte".

Sin embargo existe una sencilla para prevenir esos casos, a la vez que le da a la tabla una apariencia mas procesional, el comando \resizebox.

Este comando toma como argumento el ancho que deseamos tenga la tabla y la escala adecuadamente cambiando el tamaño de letra y grosor de las lineas, logrando que la tabla solo tenga el ancho indicado.

Para poder hacer uso de este comando es necesario incluir el paquete graphicx que viene incluido en la instalación por defecto tanto de Tex Live como de MikTeX.

El formato de este comando es el siguiente:

\resizebox{}{!} {


Es muy importante poner las llaves ya que estas delimitan donde tendrá efecto el comando.

Ahora se presentara un pequeño ejemplo con el fin de ilustrar el efecto del comando

Para esto en un documento LaTeX que contenga las declaraciones necesarias (\documentclass , \begin{document}, etc) agrege este codigo

\multicolumn{5}{|c|}{Puerto fuente} & \multicolumn{4}{|c|}{Puerto destino} \\ \hline
\multicolumn{9}{|c|}{Numero de secuencia} \\ \hline
\multicolumn{9}{|c|}{Numero de reconocimiento} \\ \hline
Longitud cabecera & Reservado & URG & ACK & PSH & RST & SYN & FIN & Tamaño ventana \\ \hline
\multicolumn{5}{|c|}{Suma verificación} & \multicolumn{4}{|c|}{Puntero a datos urgentes} \\ \hline
\multicolumn{9}{|c|}{Opciones} \\ \hline
\multicolumn{9}{|c|}{Datos} \\ \hline
\caption{Estructura de un segmento TCP.}

El cual generara una tabla como la mostrara el la figura 1

Figura 1: Tabla sin redimensionar.
Notara que la tabla queda "cortada" por el borde de la pagina y parte del contenido queda fuera vista.

Ahora remplace el codigo de la tabla por este:

\resizebox{10cm}{!} {
\multicolumn{5}{|c|}{Puerto fuente} & \multicolumn{4}{|c|}{Puerto destino} \\ \hline
\multicolumn{9}{|c|}{Numero de secuencia} \\ \hline
\multicolumn{9}{|c|}{Numero de reconocimiento} \\ \hline
Longitud cabecera & Reservado & URG & ACK & PSH & RST & SYN & FIN & Tamaño ventana \\ \hline
\multicolumn{5}{|c|}{Suma verificación} & \multicolumn{4}{|c|}{Puntero a datos urgentes} \\ \hline
\multicolumn{9}{|c|}{Opciones} \\ \hline
\multicolumn{9}{|c|}{Datos} \\ \hline
\caption{Estructura de un segmento TCP.}

Y recompile el documento, el resultado ahora lucirá como la Figura 2
Figura 2: Tabla redimensionada.

Ahora la tabla cabe perfectamente en la pagina y su contenido es perfectamente visible.


Create Search Link Between TeXstudio and SumatraPDF

I use TeXstudio for my LaTeX works. SumatraPDF is also good, lightweight PDF reader. It is possible to create a forward search from TeXstudio to SumatraPDF. You may find PDF output of a LaTeX code. Similarly, a backward search is possible: find LaTeX source code from PDF output.

Note: This post will be based on http://robjhyndman.com/hyndsight/texstudio-sumatrapdf/ . But since it was published in 2011, there are some slight changes in software menus. You may also read it. 

1 - Open TexStudio. Navigate Options -> Configure TeXstutdio...

TeXstudio options
Configure TeXstudio...

2 - Click Commands tab, and find External PDF Viewer option.
External PDF Viewer
External PDF Viewer
3 - Change it like:

"C:/Program Files (x86)/SumatraPDF/SumatraPDF.exe" -reuse-instance %.pdf

You should put your path to SumatraPDF.exe between quotation marks.

Update (08 Feb 2015): I use pdflatex. According to Vojtech Vozda (see comments), if you use DVI -> PS ->PDF chain you should also add -synctex=1 option to LaTeX part as in PdfLaTeX option in order to create search link between your source code and PDF file. See also: What exactly is SyncTeX?

4 - Click Build tab, find PDF Viewer option and change it to External PDF Viewer.
Use External PDF Viewer
Use External PDF Viewer
5 - At same window, locate User Commands tab.

User Commands
User Commands

Add the following statements:

user0:Forward Search

to first column and

dde:///"C:/Program Files (x86)/SumatraPDF/SumatraPDF.exe":SUMATRA/control/  [ForwardSearch("?am.pdf","?c:am.tex",@,0,0,1)]

to second column.

You should put your path to SumatraPDF.exe between quotation marks.

Click OK.

6 - Now let's open Options -> Configure TeXstutdio...  again and select Shortcuts tab. ExpandMenus -> Tools -> User tree. Now you should see a user command called Forward Search. Now its default shortcut is Alt+Shift+F1. But you can also assign another shortuct to forward search likeF2. But this step is optional.
User Commands Shortcut
User Commands Shortcut
7 - Now we are done with TeXstudio. Let's set up SumatraPDF. Open SumatraPDF. Click Settings -> Options.
Sumatra Settings
Sumatra Settings
8 - Locate Set inverse search command-line.
Sumatra Inverse Search
Sumatra Inverse Search

"C:\Program Files (x86)\TeXstudio\texstudio.exe" "%f" -line %l

You should put your path to texstudio.exe between quotation marks.

Click OK and exit.

Now let's try your new setup.

Compile a LaTeX code in TeXstudio and produce PDF output. If you press F2 (if you assign that shortcut in TeXstudio settings), SumatraPDF should highlight corresponding output of your cursor position. In SumatraPDF, double-clicking shows corresponding LaTeX code in TeXstudio.

Getting started with XeLaTeX

By now, most LaTeX users have prob­a­bly heard of XeLa­TeX, if only because it is an option in the lat­est ver­sions of the stan­dard LaTeX edi­tors such as TeXnic­Cen­ter,WinEdt and TeX­Works. But most LaTeX­ers have prob­a­bly not yet become XeLa­TeX­ers. Why should you?
XeLa­TeX is essen­tially a replace­ment for pdfLa­TeX. It was pri­mar­ily devel­oped to enable bet­ter font han­dling, espe­cially non-​​Roman scripts. If you want to write in Tel­ugu, then XeLa­TeX is going to make your life much eas­ier. For Eng­lish writ­ers, the main ben­e­fit of XeLa­TeX is the abil­ity to use the fonts on your com­puter, just as you can with other soft­ware. If you’ve grown to love using Geor­gia in MS-​​Word and always wanted to write a LaTeX doc­u­ment in Geor­gia, now you can.
Here is a very sim­ple example:
Note the fol­low­ing features:
  • The fontspec pack­age is almost always nec­es­sary with XeLa­TeX and con­tains com­mands to load the required fonts.
  • You usu­ally need the com­mand \defaultfontfeatures{Ligatures=TeX}. This is so the new fonts behave in the way we’ve come to expect with LaTeX, such as allow­ing an em-​​dash to be writ­ten as ---.
  • The two fonts that are loaded (Geor­gia and Tahoma in this exam­ple) are fonts avail­able in my Win­dows fonts directory.
  • The titlesec pack­age is loaded only so head­ings are in sans-​​serif bold in order to show the effect of the font changes.
  • The lip­sum pack­age pro­vides some non­sense text for test­ing purposes.
A dis­ad­van­tage of using XeLa­TeX is that most of the fonts on your com­puter will not come with enough fancy char­ac­ters (known as glyphs) for math­e­mat­ics. So maths has to be set using a stan­dard LaTeX font. Con­se­quently, I am not using XeLa­TeX for my math­e­mat­i­cal doc­u­ments, but I have started try­ing it out on non-​​mathematical documents.
For a lot more infor­ma­tion, read the fontspec man­ual.

Tables in LaTeX

Mak­ing tables in LaTeX is one of the few areas where LaTeX is more dif­fi­cult than a WYSIWYG editor.
Here are some point­ers to tools and pack­ages that I have found useful.
  • Excel2LaTeX: this excel add-​​in makes it easy to copy a rec­tan­gu­lar array of cells in a spread­sheet into a LaTeX document.
  • Calc2LaTeX: a sim­i­lar exten­sion for Libre­Of­fice and OpenOffice.
  • The LaTeX wik­i­book has a great page on pro­duc­ing tables in LaTeX.
  • Toolkit Instal­la­tor:this is a col­lec­tion of add-​​ins for WinEdt. It con­tains two fea­tures that are use­ful for tables.
    1. A graphic table designer for inputting sim­ple tables.
    2. A util­ity for mak­ing exist­ing tables neat by lin­ing up the & and remov­ing unnec­es­sary space.
  • Tuto­ri­als on tables from the Indian TeX users group:
    1. The basics
    2. Long tables
    3. Coloured tables
  • The array pack­age for apply­ing for­mat­ting com­mands to whole columns and pro­vid­ing addi­tional for­mat­ting options for paragraph-​​like columns.
  • The tab­u­larx pack­age for set­ting a table with fixed-​​width and para­graph columns with width auto­mat­i­cally calculated.
  • The book­tabs pack­age for pro­vid­ing nicer hor­i­zon­tal lines and bet­ter spac­ing control.
  • The longta­bles pack­age for tables that are too big for a sin­gle page.
  • Type­set­ting tables with LaTeX: a nice (and short) arti­cle cov­er­ing the basics as well as the above four packages.
  • Type­set­ting tables with LaTeX: video of Klaus Höpp­ner giv­ing a talk based on the above article.

Generating tables in LaTeX

Typ­ing tables in LaTeX can get messy, but there are some good tools to sim­plify the process. One I dis­cov­ered this week is tables​gen​er​a​tor​.com, a web-​​based tool for gen­er­at­ing LaTeX tables. It also allows the table to saved in other for­mats includ­ing HTML and Mark­down. The inter­face is sim­ple, but it does most things. For com­pli­cated tables, some addi­tional for­mat­ting may be necessary.

Screenshot from 2014-04-15 08:57:38

Sim­i­lar func­tion­al­ity is avail­able via plu­g­ins in ExcelOpenOf­fice and Libre­of­fice — use­ful if the data for the table is already stored in a spreadsheet.
Good LaTeX edi­tors also have built-​​in table gen­er­a­tors. For exam­ple, TeX­studio has the “Quick tab­u­lar wiz­ard” and TeX­maker has the “Tab­u­lar wiz­ard”. The one in TeX­studio is too sim­ple to be very use­ful, but the TeX­maker wiz­ard has a few more features.
Another use­ful tool to avoid the mess is the “Align columns” func­tion within TeX­studio (nor­mally shown as a blue but­ton at the top of the screen). Place the cur­sor within a table and click the but­ton, and spaces are mag­i­cally added until the columns are aligned. It also works for align, array and matrix envi­ron­ments. Here is a small exam­ple from a recent paper of mine show­ing what it does.
Screenshot from 2014-04-15 09:25:44
Screenshot from 2014-04-15 09:17:22
It is much eas­ier to spot prob­lems if the columns are aligned.

Cahnge profile in TXS

It is pos­si­ble to save the scheme in a pro­file file, and then load it on another com­puter. Sev­eral dark themes have been pro­posed on TeX​.stack​ex​change​.com. I edited one of them to cre­ate my own theme shown below.
Screenshot from 2015-03-18 13:11:22
Here is the pro­file file that imple­ments the above scheme. You should be able to load it in TeX­studio (after which you will need to re-​​start TeX­studio to see the effect).

Using TeXstudio with SumatraPDF

Tomado de http://robjhyndman.com/hyndsight/texstudio-sumatrapdf/

Suma­traPDF is my favourite pdf reader and TeX­studio is my favourite LaTeX edi­tor. Here’s how to get them to work nicely together.
Go to Options/​Configure TeX­studio and click on “Com­mands”. Beside Pdf Viewer, untick “Inter­nal viewer” and add the fol­low­ing command:
"c:/Program Files/SumatraPDF/SumatraPDF.exe" -reuse-instance %.pdf
(If you have Suma­traPDF stored some­where other than the spec­i­fied paths, you will need to edit this accordingly.)
Then you need to tell Suma­traPDF how to jump to the cor­rect line in TeX­studio. From within Suma­traPDF, go to Settings/​Options and set the inverse search com­mand to
"C:\Program Files\TeXstudio\texstudio.exe" "%f" -line %l
Change the path to TeX­studio if necessary.
In order to go from the tex file to the cor­re­spond­ing loca­tion in the pdf, you can add a For­ward­Search com­mand within TeX­studio. Select “User” from the main menu, then “User com­mands” and “Edit User com­mands”. Then add a com­mand with the fol­low­ing definition:
dde://"C:/Program Files/SumatraPDF/SumatraPDF.exe":SUMATRA/control/
(That should all be on one line with no space before [ForwardSearch. Again, edit the path for Suma­traPDF as nec­es­sary. Give the com­mand a name such as “For­ward­Search” and click “OK”. Now you should be able to jump to the cor­re­spond­ing part of the pdf file using “Alt-​​Shift-​​F1” (or what­ever key-​​combination is asso­ci­ated with your new command).
Being lazy, I pre­fer a sim­ple func­tion key. To map F2 to your new com­mand, select “Options/​Configure TeX­studio” and choose “Short­cuts”. Find your new com­mand under the User menu, dou­ble click to the right of it and select “F2” from the drop-​​down box. Pre­vi­ously F2 was mapped to LaTeX, but I never use LaTeX directly, so los­ing this func­tion is no problem.
Now you can dou­ble click on any part of the pdf from within Suma­traPDF and it should take you to the cor­re­spond­ing place in your tex file in TeX­studio. And thenF2 will take you back again.