Graphics, Figures & Tablesctabular with Memoir class, changing font size

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
west.logan
Posts: 87
Joined: Tue Sep 14, 2010 6:58 pm

ctabular with Memoir class, changing font size

Post by west.logan »

I'm trying to globally change the font size for all of the ctabular environments I've used in a book and cannot seem to figure out how to do that. First, a MWE:

Code: Select all

\documentclass{memoir}

%\let\oldCtabular\ctabular
%\renewcommand{\ctabular}{\oldCtabular\small}

\begin{document}

This is a demo table:

\begin{ctabular}{lll}
Item1 &Item2 &Item3\\
Item4 &Item5 &Item6\\
\end{ctabular}

\end{document}
The commented section is what I originally tried. I have also tried renewing the environment, and looking at the Memoir class code, but am not sure what to do with it.

Code: Select all

\newcommand*{\ctabular}[1][c]{\global\@curtab\@ne
  \ctableftskip\fill
  \ctabrightskip\fill
  \if l#1% left
    \ctableftskip\z@
  \else
    \if r#1% right
      \ctabrightskip\z@
    \fi
  \fi
  \gdef\@halignto{to\hsize}\NC@tabular}
Are there any immediately obvious ways I can change the font size within ctabular?
Last edited by west.logan on Mon Mar 07, 2011 6:59 pm, edited 1 time in total.

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

ctabular with Memoir class, changing font size

Post by localghost »

west.logan wrote:[…] Are there any immediately obvious ways I can change the font size within ctabular?
You are on the right path. You just have to draw it to an end.

Code: Select all

\documentclass{memoir}

\makeatletter
\renewcommand*{\ctabular}[1][c]{%
  \global\@curtab\@ne
  \small                 % the font size switch
  \ctableftskip\fill
  \ctabrightskip\fill
  \if l#1% left
    \ctableftskip\z@
  \else
    \if r#1% right
      \ctabrightskip\z@
    \fi
  \fi
  \gdef\@halignto{to\hsize}\NC@tabular
}
\makeatletter

\begin{document}
  This is a demo table:

  \begin{ctabular}{lll}
    Item1 & Item2 & Item3 \\
    Item4 & Item5 & Item6 \\
  \end{ctabular}
\end{document}

Thorsten
west.logan
Posts: 87
Joined: Tue Sep 14, 2010 6:58 pm

Re: ctabular with Memoir class, changing font size

Post by west.logan »

Thank you Thorsten. It turns out that there are some things wrong with the "marginfix" package I was using, that causes strange errors such as throwing all kinds of "too many unprocessed float" errors when this redefinition is made, changing heading spacing, and even legend spacing on tables. It's quite odd that the package does all of this.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

ctabular with Memoir class, changing font size

Post by localghost »

west.logan wrote:[…] It turns out that there are some things wrong with the "marginfix" package I was using, that causes strange errors such as throwing all kinds of "too many unprocessed float" errors when this redefinition is made, changing heading spacing, and even legend spacing on tables. It's quite odd that the package does all of this.
What happens if you place the font switch as very first line of the redefinition? Sometimes the sequence of commands has strange effects.
west.logan
Posts: 87
Joined: Tue Sep 14, 2010 6:58 pm

ctabular with Memoir class, changing font size

Post by west.logan »

I get the same error. The LaTeX error is "too many unprocessed floats" (which goes away if I don't use the Marginfix package). The generic error is:

Code: Select all

\GenericError  ...                                
                                  \endgroup 
<argument> \@floatpenalty \z@ \@fltovf 
                          \def \@currbox {\@tempboxa }\def \@ma...

\@next #1#2#3#4->\ifx #2\@empty #4
                      \else \expandafter \@xnext #2\@@ #1#2#3\fi 
\oldM ...{\@tempboxa }\def \@marbox {\@tempboxa }}
                                \fi \@ifnextchar [\@xmpar ...

\marginpar #1->\oldM 
        [\vspace {3pt}\raggedright \footnotesize \sffamily #1]{...
l.468 ...ritons persecuted by the heathen Saxons.}
                                                  %
As I said before, the marginfix package has caused a lot of little odd errors. Your suggestions seem to be fine, it's just the package that has a problem.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: ctabular with Memoir class, changing font size

Post by localghost »

So this seems to be worth either a note to the package or the class maintainer.
west.logan
Posts: 87
Joined: Tue Sep 14, 2010 6:58 pm

ctabular with Memoir class, changing font size

Post by west.logan »

Yes, and I did contact the package creator about all the issues I'd run into so far.

I should also note that I am renewing the command for \marginpar to make the font smaller. Because the Marginfix package then had some strange vertical shifts and reversal of left/right margins, I had to do some squirrely changes. However, even when this renewcommand is removed, the "too many unprocessed floats" error remains. The error even remains when no font switch is inserted.

Code: Select all

\let\oldM\marginpar
\renewcommand\marginpar[1]{\oldM[\vspace{3pt}\raggedright\footnotesize\sffamily #1]%
{\vspace{3pt}\raggedleft\footnotesize\sffamily #1}}
Post Reply