GeneralReport Layout

LaTeX specific issues not fitting into one of the other forums of this category.
User avatar
cbustaam
Posts: 57
Joined: Mon Sep 01, 2008 10:17 pm

Re: Report Layout

Post by cbustaam »

Thanks gmedina... It works well.

Solved this, I had two more questions (I hope not to be annoying):
1. How can I edit the apparence of floats (figures, table) to get something like the first image? I only want to customize, not create a new one.

2. If I want to create a cls file with this apparence, How can I put the preable in a modified version of report cls file?

Bests
"Show me your .emacs and I'll tell you who you are." -- modified proverb

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Report Layout

Post by gmedina »

Hi,

1- You can use some of the features provided by the float package to change the format of floats (please refer to the package documentation for further information). The following sample code can give you some ideas:

Code: Select all

\documentclass{report}
\usepackage[svgnames]{xcolor}
\usepackage{float}

\makeatletter
\renewcommand\floatc@ruled[2]%
  {\setbox\@tempboxa\hbox{#2}%
   \ifdim\wd\@tempboxa>\hsize #2\par%
   \else\hbox to\hsize{\hfil\box\@tempboxa\hfil}\fi}
\renewcommand\fs@ruled{\def\@fs@cfont{\bfseries}\let\@fs@capt\floatc@ruled%
  \def\@fs@pre{\vspace*{-20pt}\hrulefill\lower.8ex
    \hbox{\colorbox{MidnightBlue}{%
      \textcolor{white}{\scriptsize GR\'AFICO\ \thefigure}}}%
    \hrulefill\vspace{10pt}}%
  \def\@fs@post{\vspace{3pt}\kern2pt\hrule\relax}%
  \def\@fs@mid{\addvspace{10pt}}
  \let\@fs@iftopcapt\iftrue}
\makeatother

\floatstyle{ruled}
\restylefloat{figure}

\begin{document}

\begin{figure}[!ht]
	\centering
  \rule{4cm}{2cm}
	\caption{A test figure}
	\label{fig:test}
\end{figure}

\end{document}
The idea was to redefine the \fs@ruled command (as defined in float.sty) to include the centered box with the colored box containing "GRÁFICO <number>", and erasing the midlle rule. The above code also redefines the \floatc@ruled that formats the caption for the new ruled floats.

2- I do not completely understand your question. Do you want to know how to create a class file?
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
cbustaam
Posts: 57
Joined: Mon Sep 01, 2008 10:17 pm

Report Layout

Post by cbustaam »

That works great. I only had should to define a diferent \vspace* value because the float overrides the text before it.
gmedina wrote: 2- I do not completely understand your question. Do you want to know how to create a class file?
Yes, I want to create a class file with the options that I defined at the preamble of this tex file.
"Show me your .emacs and I'll tell you who you are." -- modified proverb
User avatar
cbustaam
Posts: 57
Joined: Mon Sep 01, 2008 10:17 pm

Re: Report Layout

Post by cbustaam »

One more question: I don't decide yet if the document are going to be in one or two columns, but to use this float, I need one column. I can define in the modified environment a chage before on columns before and after float?
"Show me your .emacs and I'll tell you who you are." -- modified proverb
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Report Layout

Post by gmedina »

Hi,
cbustaam wrote:One more question: I don't decide yet if the document are going to be in one or two columns, but to use this float, I need one column. I can define in the modified environment a chage before on columns before and after float?
In order to make the figure span both columns, you can use the figure* environment instead of the un-starred figure environment.

The clsguide document contains useful information for writting classes.
Last edited by gmedina on Mon Aug 03, 2009 5:27 am, edited 1 time in total.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
cbustaam
Posts: 57
Joined: Mon Sep 01, 2008 10:17 pm

Report Layout

Post by cbustaam »

Thanks a lot for your help... After I do a good preamble, I'm going to check out the clsguide to make it a document class.

I have one more question: If I want to set as default the following table style, how can I do it? I put this line

Code: Select all

\restylefloat{table}
To get an environment similar to figure, but in the title appears "GRAFICO". So, I need to appears "GRAFICO" for figure envirnment, and "CUADRO" for the table one. Also, I need to set up the colored rows and table headers.
Table.JPG
Table.JPG (31.87 KiB) Viewed 5132 times
Regards
"Show me your .emacs and I'll tell you who you are." -- modified proverb
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Report Layout

Post by gmedina »

Hi,

the following code contains the new redefinitions for tables and a sample table like the one you need:

Code: Select all

\documentclass{report}
\usepackage[margin=2cm]{geometry}
\usepackage{array}
\usepackage[table,svgnames]{xcolor}
\usepackage{float}

\makeatletter
\renewcommand\floatc@ruled[2]%
  {\setbox\@tempboxa\hbox{#2}%
   \ifdim\wd\@tempboxa>\hsize #2\par%
   \else\hbox to\hsize{\hfil\box\@tempboxa\hfil}\fi}
\renewcommand\fs@ruled{\def\@fs@cfont{\bfseries}\let\@fs@capt\floatc@ruled%
  \def\@fs@pre{\vspace*{0pt}\hrulefill\lower.8ex
    \hbox{\colorbox{MidnightBlue}{%
      \textcolor{white}{\scriptsize GR\'AFICO\ \thefigure}}}%
    \hrulefill\vspace{10pt}}%
  \def\@fs@post{\vspace{3pt}\kern2pt\hrule\relax}%
  \def\@fs@mid{\addvspace{10pt}}
  \let\@fs@iftopcapt\iftrue}

\renewcommand\floatc@plain[2]%
  {\setbox\@tempboxa\hbox{#2}%
   \ifdim\wd\@tempboxa>\hsize #2\par%
   \else\hbox to\hsize{\hfil\box\@tempboxa\hfil}\fi}
\renewcommand\fs@plain{\def\@fs@cfont{\bfseries}\let\@fs@capt\floatc@plain%
  \def\@fs@pre{\vspace*{0pt}\hrulefill\lower.8ex
    \hbox{\colorbox{MidnightBlue}{%
      \textcolor{white}{\scriptsize CUADRO\ \thetable}}}%
    \hrulefill\vspace{10pt}}%
  \def\@fs@post{\vspace{3pt}\kern2pt\hrule\relax}%
  \def\@fs@mid{\addvspace{10pt}}
  \let\@fs@iftopcapt\iftrue}
\makeatother

\floatstyle{ruled}
\restylefloat{figure}
\floatstyle{plain}
\restylefloat{table}

\newcommand\myc[1]{%
  \multicolumn{1}{c!{\color{white}\vline width 1pt}}{\cellcolor{MidnightBlue}\color{white} #1}}
\newcommand\mycf[1]{%
  \multicolumn{1}{c}{\cellcolor{MidnightBlue}\color{white} #1}}

\begin{document}

\begin{table}[!ht]
  \centering\footnotesize
  \setlength\arraycolsep{0pt}
  \setlength\extrarowheight{2pt}
  \rowcolors{2}{MidnightBlue!25}{MidnightBlue!5}
  \begin{tabular}{>{\raggedright\arraybackslash}m{4.8cm}*{7}{!{\color{white}%
  \vline width 1pt}>{\centering\arraybackslash}m{1.3cm}}}       
    \rowcolor{MidnightBlue}\myc{\rule[-7pt]{0pt}{19pt}Medida} & \myc{Argentina} & \myc{Bolivia} &%
     \myc{Brasil} & \myc{Chile} & \myc{Colombia} & \myc{M\'exico} & \mycf{Per\'u}\\
    Ajuste excepcional a las operaciones de mercado (frecuencia y opciones) &&&&& X &&\\
    Disminuci\'on en el encaje sobre dep\'ositos & X & X & X & & X & & X\\
    Mecanismos de liquidez en moneda extranjera &&& X & X && X & X\\
    Intervenci\'on en el mercado de divisas y/o ajustes en los mecanismos & X &&&& X & X & X\\ 
    Cambios en las facilidades de cr\'edito & X &&& X &&&\\ 
    Reducci\'on de las tasas de intervenci\'on &&&&&&& 
  \end{tabular}
  \caption{MEDIDAS DE POL\'ITICA MONETARIA EN LA SEGUNDA PARTE DEL A\~NO}
  \label{tab:test}
   
  \hspace*{-12.5cm}Fuente: Bancos centrales de cada pa\'is.
\end{table}

\end{document}
For further information, please refer to the documentation of the used packages. Of course, feel free to modify my example according to your needs.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
cbustaam
Posts: 57
Joined: Mon Sep 01, 2008 10:17 pm

Report Layout

Post by cbustaam »

Hi gmedina
Again, thanks for your reply. I have a problem when I try to compile the code with 12pt or 11pt font size. I got something like
Figerr.JPG
Figerr.JPG (53.68 KiB) Viewed 5106 times
What can I do?
"Show me your .emacs and I'll tell you who you are." -- modified proverb
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: Report Layout

Post by gmedina »

Increase the columns' width.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
cbustaam
Posts: 57
Joined: Mon Sep 01, 2008 10:17 pm

Re: Report Layout

Post by cbustaam »

Doh, Obvious... silly question.
Thanks for your help.
"Show me your .emacs and I'll tell you who you are." -- modified proverb
Post Reply