3

Considering the following TeX code:

\documentclass{article}

\begin{document}
  \begin{itemize}
    \item[1] abc
    \item[2] def
  \end{itemize}
\end{document}

How one can change the font size of 1..2 item numbers?

Werner
  • 603,163
Shahzad
  • 1,297
  • 14
  • 19

1 Answers1

3

Like this, you mean?

\documentclass{article}
\usepackage{enumitem}
\setlist[enumerate]{font=\huge\bfseries}

\begin{document}
  \begin{enumerate}
    \item abc
    \item def
  \end{enumerate}
\end{document}

Note that your

  \begin{itemize}
    \item[1] abc
    \item[2] def
  \end{itemize}

May not be doing what you want. You are asking for an 'itemize' environment, then overriding the bullets normally provided with a manual set of enumerate numbers. You may prefer to use \begin{enumerate} \item ... \end{enumerate} as I wrote above.

If you need or want to use the itemize environment, you could adapt my suggestion and use:

\usepackage{enumitem}
\setlist[itemize]{font=\huge\bfseries}

Compare the output:

\documentclass{article}
\usepackage{enumitem}
\setlist[enumerate]{font=\huge\bfseries}
\setlist[itemize]{font=\huge\bfseries}

\begin{document}
  \begin{enumerate}
    \item abc
    \item def
  \end{enumerate}

  \begin{itemize}
    \item[1] abc
    \item[2] def
  \end{itemize}
\end{document}

Provisional Edit (If this solves the problem, please edit the question so it is useful to others in the future.)

Given the link mentioned in the comments, and the stated desire to not change the documents as they stand (which I don't recommend as a general practice), perhaps this is what you are looking for:

Add this line to your preamble (modify characteristics as needed):

\setbeamerfont*{shahzad}{size=\footnotesize,series=\bfseries,shape=\itshape}

Then substitute

\usebeamerfont*{shahzad}    

for

\usebeamerfont*{itemize \beameritemnestingprefix item}%

Complete example:

\documentclass{beamer}
\usepackage{lmodern}

\setbeamerfont*{shahzad}{size=\footnotesize,series=\bfseries,shape=\itshape}

\makeatletter
\newcommand\ChangeItemFont[3]{%
\renewcommand{\itemize}[1][]{%
  \beamer@ifempty{##1}{}{\def\beamer@defaultospec{#1}}%
  \ifnum \@itemdepth >2\relax\@toodeep\else
    \advance\@itemdepth\@ne
    \beamer@computepref\@itemdepth% sets \beameritemnestingprefix
    \usebeamerfont{itemize/enumerate \beameritemnestingprefix body}%
    \usebeamercolor[fg]{itemize/enumerate \beameritemnestingprefix body}%
    \usebeamertemplate{itemize/enumerate \beameritemnestingprefix body begin}%
    \list
      {\usebeamertemplate{itemize \beameritemnestingprefix item}}
      {\def\makelabel####1{%
          {%
            \hss\llap{{%
%          \usebeamerfont*{itemize \beameritemnestingprefix item}%
          \usebeamerfont*{shahzad}%
          \usebeamercolor[fg]{itemize \beameritemnestingprefix item}####1}}%
          }%
        }%
  \ifnum\@itemdepth=1\relax
    #1%
  \else
  \ifnum\@itemdepth=2\relax
    #2%
  \else
  \ifnum\@itemdepth=3\relax
    #3%
  \fi%
  \fi%
  \fi%
  }
  \fi%
  \beamer@cramped%
  \raggedright%
  \beamer@firstlineitemizeunskip%
}}
\makeatother

\begin{document}

\begin{frame}
\frametitle{Font size changed}
\ChangeItemFont{\fontsize{30}{36}\selectfont}{\scriptsize}{\LARGE}
\begin{itemize}
\item[1] First item. % <-- note this one
  \begin{itemize}
  \item First subitem.
    \begin{itemize}
    \item[1] First subsubitem. % <-- note this one
    \item Second subsubitem.
    \item Third subsubitem.
    \item Fourth subsubitem.
    \end{itemize}
  \item Second subitem.
  \end{itemize}
\item Second item.
\item Third item.
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Regular font size}
\begin{itemize}
\item First item.
  \begin{itemize}
  \item First subitem.
    \begin{itemize}
    \item[1] First subsubitem.
    \item Second subsubitem.
    \item Third subsubitem.
    \item Fourth subsubitem.
    \end{itemize}
  \item Second subitem.
  \end{itemize}
\item Second item.
\item Third item.
\end{itemize}
\end{frame}

\end{document}

Ultimately, though, you should change your practices for future documents. Using itemize environments for enumerate ones will lead to problems in the long run.

jon
  • 22,325
  • @Mico -- Good point! I'll edit the answer. – jon Mar 01 '16 at 06:26
  • Is it possible to do this without using enumitem package? – Shahzad Mar 01 '16 at 06:36
  • @Shahzad -- Yes (otherwise the enumitem package couldn't do it either). But not as easily. In my view, for list-related environments, enumitem is the canonical package to use. Why do you wish to avoid it? – jon Mar 01 '16 at 06:39
  • Because I have several documents which are using some font related stuff for itemize environment (at slide level) and I don't want to redo everything again because of less time. The trick would do great if there is one without using enumitem package. – Shahzad Mar 01 '16 at 06:48
  • The "trick" would involve adding code to every document and would be longer than two lines I've posted, so it would be more work to not use the package. What kind of trick do you have in mind that would not involve changing the documents? – jon Mar 01 '16 at 07:00
  • I am not a TeX expert but I am using the code from http://tex.stackexchange.com/questions/130540/in-beamer-change-fontsize-of-selected-slides-with-nested-lists – Shahzad Mar 01 '16 at 07:05
  • 1
    That is important to mention in your question. However, what is the problem, then? If you do your \item[1] and forth in the code of the answer there, the 1 does change size to match the font of the list item. What do you want it to do? – jon Mar 01 '16 at 07:15
  • Actually, I would like to reduce the size of item number than the item itself. For example, if the item size is 16pt, then I want item number to be of size say 14pt. – Shahzad Mar 01 '16 at 07:37
  • @Shahzad -- Indeed, and that is what the example does (note the part that says \size=\footnotesize). Do you mean you want relative fontsize changes? Do you want to specify different values for different lists? There are now too many unknowns. Please revise your question and explain clearly what you want. Your minimal example is much appreciated, but in this case is too minimal. – jon Mar 02 '16 at 01:45
  • @Shahzad -- Note: I quite certain that what you want can be achieved with very minimal changes to the code given above. However, what you want, precisely, is still unclear. – jon Mar 02 '16 at 01:57