General ⇒ What variable current section name?
What variable current section name?
I want to display the name of the section (also chapter, subsection) I'm currently in. (Section number doesn't do)
For instance:
\begin{document}
\section{asdf}
This is text in the section: ??? % and here I need something to display "asdf" without explicitly typing it)
\end{document}
Thanks a lot,
Daniel
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
-
- Posts: 8
- Joined: Tue Jul 21, 2009 12:13 pm
Re: What variable current section name?
Here is what I did. Make a variable that stores the current section title.
ie
\definecommand{sectiontitle}{#1}
\definecommand{setsectiontitle}[1]{\renewcommand{sectiontitle}{#1}}
and use \sectiontitle inside the section...
Trust me on this-- I know exactly what you're trying to do, after investing literally 20 or so hours into this,
\section{Quadratic Equations}
\setsectiontitle{Quadratic Equations}
{
...
}
What variable current section name?
Wouldn't have been easier just to define a command like this:stantestco wrote: \section{Quadratic Equations}
\setsectiontitle{Quadratic Equations}
\newcommand{\sectiontitle}{}
\newcommand{\newsection}[1]{\section{#1}\renewcommand{\sectiontitle}{#1}}
So that in the document you only need to do:
\newsection{Quadratic Equations}
which will both start the new section and redefine \sectiontitle?
But I think there should be a way to get around even doing that, but I think we'd need to know what document class and other packages were being used.
Re: What variable current section name?
@frabjous: Documentclass is report and I can integrate all packages needed if it facilitates the solution.
What variable current section name?
this solved my problem. I could even easily extend the functionality to subsectiontitles ...
I don't quite grasp the exact syntax of the commands you gave, but I encountered those while searching on "\sectionmark" which was the closest I got to a "solution" after literally hours of searching. Everything I encountered was about headers and so on, but I didn't want some "fancy headers", just a title on my slides in the "beamer class" that would change automatically if I ever wanted to change the name of the section. It now also provides easier processing, since I can use the same lines over and over again.
Thanks a lot.
Prosper
What variable current section name?
When I use this snippet of code
Code: Select all
\AtBeginSection[]
{
\begin{frame}
\frametitle{\sectiontitle}
\tableofcontents[currentsection,hideothersubsections,]
\end{frame}
}
Placing everything inside the brackets manually AFTER each session-start gives the intended result: correct sessiontitle and correct highlighted "upcoming" session.
Though this suits my needs, it is rather cumbersome...
BTW: document class is Beamer
What variable current section name?
Code: Select all
\newcommand{\sectiontitle}{}
\newcommand{\newsection}[1]{\section{#1}\renewcommand{\sectiontitle}{#1}}
If so, did you try changing it to:
Code: Select all
\newcommand{\sectiontitle}{}
\newcommand{\newsection}[1]{\renewcommand{\sectiontitle}{#1}\section{#1}}
What variable current section name?
The nameref package will do this (but you need to label the section):dmader wrote: I want to display the name of the section (also chapter, subsection) I'm currently in. (Section number doesn't do)
Code: Select all
\documentclass{report}
\usepackage{nameref}
\begin{document}
\chapter{Sample}
\section{asdf}\label{sec:ex}
This is text in the section: \nameref{sec:ex}.
\end{document}
Code: Select all
\documentclass{beamer}
\AtBeginSection[]
{
\begin{frame}
\frametitle{\insertsectionhead}
\tableofcontents[currentsection,hideothersubsections,]
\end{frame}
}
\begin{document}
\section{asdf}
\begin{frame}
\frametitle{Sample}
\end{frame}
\end{document}
Nicola Talbot
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/