Font size of Chapter and Chapter Title - latex

I am trying to make the title CHAPTER 1 is aligned in the center and the title of the chapter is aligned to the left.
\titleformat{\chapter}[display]
{\large\bfseries}{\filcenter\chaptertitlename\ \thechapter}
{20pt}{\MakeUppercase{#1}}
\titlespacing*{\chapter}
{0pt}{0pt}{20pt} %controls vertical margins on title
But, then how can I change the font size? that is, for example, I need "CHAPTER 1" smaller than the title "Introduction".

You can change the font size by adding a command right before #1, like so:
\documentclass{book}
\usepackage[explicit]{titlesec}
\titleformat{\chapter}[display]
{\large\bfseries}{\filcenter\chaptertitlename\ \thechapter}
{20pt}{\Huge\MakeUppercase{#1}}
\titlespacing*{\chapter}
{0pt}{0pt}{20pt} %controls vertical margins on title
\usepackage{lipsum}
\begin{document}
\chapter{Introduction}
\lipsum[1]
\end{document}

Related

adjusting side caption in latex

I would like to adjust the side caption in latex by having the caption flushed left (or right) and be aligned with the top of the figure.
Attached is a MWE
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[ragged]{sidecap}
\begin{document}
\begin{SCfigure}
\includegraphics[width=5cm]{name}
\caption{I would like the caption to occupy say 0.2linewidth and be left (or right) adjusted and on top}\label{fig:testA}
\end{SCfigure}
\end{document}
To have the caption either flush left or right, the sidecap package offers the options raggedright and raggedleft.
To align the caption with the top of the figure, you can use \sidecaptionvpos{figure}{t}
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[
%ragged
%raggedright
raggedleft
]{sidecap}
\sidecaptionvpos{figure}{t}
\begin{document}
\begin{SCfigure}
\includegraphics[width=5cm]{name}
\caption{I would like the caption to occupy say 0.2linewidth and be left (or right) adjusted and on top}\label{fig:testA}
\end{SCfigure}
\end{document}

How to increase font size of just chapter names in latex

need of a small guidance here.
I am using report class, and I do not need chapter numbers for every chapter, just the chapter names.
Is there a way to increase just the font size of the chapter names?
\documentclass[11pt]{report}
\usepackage[utf8]{inputenc}
\begin{document}
\chapter{Introduction}
\end{document}
Observation:
Chapter number is to be removed. I would really appreciate any guidance to increase the font size of the chapter name.
I tried the following to remove chapter numbers. But font size is causing a little concern
\titleformat{\chapter}[display]
{\normalfont\bfseries}{}{5pt}{\huge}
Thanks
You can control the font size of the chapter title with the third argument of \titleformat. In your example, this was \normalsize, change this to whatever size you like:
\documentclass[11pt]{report}
\usepackage{lmodern}
\usepackage{titlesec}
\titleformat{\chapter}[display]{\fontsize{56pt}{64pt}\bfseries}{}{5pt}{}
\begin{document}
\chapter{Introduction}
text
\end{document}

latex beamer footer alignment

How can I add text line on left side and frame number on right side of footer in latex beamer presentation?
Also, I need to exclude title page from this footer placement.
Found a solution:
To obtain text and frame number as required, the following code is needed in the beginning.
\setbeamertemplate{footline}{text line}{text here \hspace{3cm} \insertframenumber{}/\inserttotalframenumber}
Instead of adding the frame number to the textline template, I find it easier to do it the other way round and add some text to the predefined framenumber footline:
\documentclass{beamer}
\setbeamertemplate{footline}[frame number]
\addtobeamertemplate{footline}{\hskip1em text you want to add}{}
\begin{document}
\begin{frame}
content...
\end{frame}
\end{document}

Beamer Headline setup

I'm currently working on an own beamer template (actually I'm trying to remodell an existing power point design so I can do my presentations using Latex).
The existing template has a titlebar which shows a logo on the right and a small colored bar below the bar. This titlebar is shown for the titlepage, as well as for the text slides. Within the textslides the titlebar also contains the current frames title and subtitle, each in i its own font size and color.
Using the beamer user guide and other templates, I figured that every frame has a headline, which is sometimes used to show the current section, and a frame title where usually the frametitle and subtitle are shown. The headline is shown topmost, followed by the frame title. The frame title however, is not shown on the titlepage.
A (I hope as minimal as possible) working example of my setup is:
\setbeamercolor*{frametitle}{fg=white,bg=blue}
\setbeamercolor*{framesubtitle}{fg=gray,bg=blue}
\defbeamertemplate*{headline}{formusic}
\ifx\insertframetitle\#empty%
\begin{beamercolorbox}[wd=\paperwidth, ht=1.5cm]{frametitle}
\hfill
\includegraphics[scale=0.15]{logo.png}
\end{beamercolorbox}
\else%
\fi%
\defbeamertemplate*{frametitle}{formusic}
\ifx\insertframetitle\#empty%
\begin{beamercolorbox}[wd=\paperwidth, ht=1.5cm]{frametitle}
\end{beamercolorbox}
\else%
\ifx\insertframesubtitle\#empty%
\begin{beamercolorbox}[wd=\paperwidth, ht=1.5cm]{frametitle}
\raisebox{0.55cm}{\insertframetitle}
\hfill
\includegraphics[scale=0.15]{logo.png}
\end{beamercolorbox}
\else%
\hbox{
\vbox{
\begin{beamercolorbox}[wd=\paperwidth, ht=0.7cm]{frametitle}
\insertframetitle
\end{beamercolorbox}
\begin{beamercolorbox}[wd=\paperwidth, ht=0.7cm]{framesubtitle}
\insertframesubtitle
\end{beamercolorbox}}
\includegraphics[scale=0.15]{logo.png}}
\fi
\fi%
The results of this can be seen in these slide headers. For the first, the titlepage this looks fine (I used the blue background color in order to visualize my problems), however for the other slides it does not look that good.
The headline does not seem to support the '\insertframe(sub)title' commands. Therefore I use a workaround where I display the empty titlebar within the headline for the first page with ifnum\c#framenumber=1, and for all other pages an empty headline. On these slides, the titlebar is displayed by the frametitle. This works - almost - as there is still a small white line visible between the frametitle and the top border of the slide.
My second problem is: How do I ideally arange the frametitle, -subtitle and logo in my titlebar? I played around a lot with beamercolorboxes, however I'm not 100% satisfied with what I have achieved so far. My attempt would be to have the frametitle and the subtitle in separate beamercolorboxes (this seems to be the most clean attempt, since I can use separately defined layouts for each, instead of switching font size and color), which are below each other. However now I don't know how to position the logo.
Edit: Added code example and images according to Werners suggestion and edited the text acordingly.
A quick workaround: not use a headline at all, but make sure that the frametitle will be shown on all frames, even those without frametitle:
\documentclass{beamer}
\setbeamertemplate{headline}{}
\setbeamercolor{frametitle}{fg=white,bg=blue}
\setbeamercolor{framesubtitle}{fg=gray,bg=blue}
\makeatletter
\patchcmd{\endbeamer#frameslide}{\ifx\beamer#frametitle\#empty}{\iffalse}{}{\errmessage{failed to patch}}
\makeatother
\makeatletter
\setbeamertemplate{frametitle}{%
\ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
\#tempdima=\textwidth%
\advance\#tempdima by\beamer#leftmargin%
\advance\#tempdima by\beamer#rightmargin%
\begin{beamercolorbox}[sep=0.3cm,left,wd=\the\#tempdima]{frametitle}
\begin{minipage}{.81\paperwidth}
\usebeamerfont{frametitle}%
\vbox{}\vskip-1ex%
\if#tempswa\else\csname beamer#fteleft\endcsname\fi%
\strut\insertframetitle\par%
{%
\ifx\insertframesubtitle\#empty%
\else%
{\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\strut\insertframesubtitle\par}%
\fi
}%
\end{minipage}%
\quad\raisebox{-0.3cm}{\includegraphics[width=.1\paperwidth]{example-image-duck}}
\if#tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
\end{beamercolorbox}%
}
\makeatother
\begin{document}
\begin{frame}
abc
\end{frame}
\begin{frame}
\frametitle{title}
abc
\end{frame}
\begin{frame}
\frametitle{very long title which possible spans over multiples lines...}
abc
\end{frame}
\begin{frame}
\frametitle{title}
\framesubtitle{subtitle}
abc
\end{frame}
\begin{frame}
abc
\end{frame}
\end{document}

Latex: center text within listing

How do I center text within a listing in Latex?
Or another way not using listing. (Need a box with monospace font)
The answer given at tex.stackexchange is:
\documentclass{article}
\usepackage{listings}
\renewcommand{\figurename}{Listing}
% replace figurename with the text that should preceed the caption
\begin{document}
\begin{figure}[thp] % the figure provides the caption
\centering % which should be centered
\caption{Ausgabe des C-Programms}
\begin{tabular}{c} % the tabular makes the listing as small as possible and centers it
\begin{lstlisting}[label={gtt_c_ausgabe}]
printf("Your code goes here.\n");
\end{lstlisting}
\end{tabular}
\end{figure}
\end{document}
...which still leaves me wondering:
Using a frame around the code, e.g. using \lstset{frame=single,frameround=tttt}, places the frame way over to the right. How can this be avoided?
What does the renewcommand bit do?
I don't have an answer for the listing package on top of my head, but you could try the following:
\framebox[.9\linewidth]{\parbox{.85\linewidth}{\tt Hello World\\Second line}}
That produces a box with 90% of the line width, with text of width 85% of line width.
If you want it centered you just put \centering in front of the \tt command:
\framebox[.9\linewidth]{\parbox{.85\linewidth}{\centering \tt Hello World\\Second line}}
If you prefer the box without a frame, simply change \framebox into \makebox (and keep the arguments as they stand).

Resources