11

I have small graph in my presentation (I have to). To adjust the size of the legend, I have to use very small legend. But \tiny is not enought.

Here is a MWE :

\documentclass{beamer}
\usepackage{etex}
\usepackage[frenchb]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{epstopdf}
\usepackage{tikz}
\usepackage{circuitikz}
\usepackage{pstricks}
\usepackage{array}
\usepackage{graphicx}
\usepackage{filecontents}

\begin{filecontents}{data.dat}
x,y
1,2
2,3
3,4
\end{filecontents}

\begin{document}
\begin{frame}
\begin{tikzpicture}
    \begin{axis}[
        legend style={font=\tiny},
        xlabel={x},
        ylabel={y},
        width=4cm, height=3cm,
        ymin=0,
        xmin=0,
        xmajorgrids, xminorgrids, ymajorgrids,
    ]   
    \addplot table [col sep=comma]{data.dat};
    \addlegendentry{Test Test Test};
    \end{axis}  
\end{tikzpicture}
\end{frame}
\end{document}

Giving this :

enter image description here

2
  • 1
    Do you want the legend to be read only with a magnifying glass? ;o) – Bernard Jul 29 '15 at 15:50
  • I exagerated the problem to show you ^^ – zeslayer Jul 29 '15 at 15:50
15

beamer has the additional font switch \Tiny that will give you a smaller size than \tiny (if your current font supports this size); if this is not enough, you can use \fontsize{<size>}{<baselineskip>}\selectfont with appropriate values.

enter image description here

The code:

\documentclass{beamer}
\usepackage{etex}
\usepackage[frenchb]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{epstopdf}
\usepackage{tikz}
\usepackage{circuitikz}
%\usepackage{pstricks}
\usepackage{array}
\usepackage{graphicx}
\usepackage{filecontents}

\begin{filecontents}{data.dat}
x,y
1,2
2,3
3,4
\end{filecontents}

\begin{document}
\begin{frame}
\begin{tikzpicture}
    \begin{axis}[
        legend style={font=\fontsize{4}{5}\selectfont},
        xlabel={x},
        ylabel={y},
        width=4cm, height=3cm,
        ymin=0,
        xmin=0,
        xmajorgrids, xminorgrids, ymajorgrids,
    ]   
    \addplot table [col sep=comma]{data.dat};
    \addlegendentry{Test Test Test};
    \end{axis}  
\end{tikzpicture}
\end{frame}
\end{document}
3
  • It looks like like it's impossible to have less than 5 in size. So I don't manage to go really down in size. Maybe there is really a limit... – zeslayer Jul 29 '15 at 16:00
  • 3
    @zeslayer As I mentioned in my answer, it all depends on the font you are using; wheter it is scalable to the desired font size or not. For example, using the lmodern fonts: \usepackage{lmodern} you can get sizes of 1pt with no problem. – Gonzalo Medina Jul 29 '15 at 16:04
  • Ok. The the problem is my font ! Thanks a lot. Problem solved. – zeslayer Jul 29 '15 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.