Based upon this original post include section name, as well as number in mdframed (theorem) header, I am using tikz to create a series of bars and markers (e.g. Topic No, Summary, topic summary), thus:
After innumerable hours of development and experimentation, I seemed to have reached a limit and am requesting help to complete the development of this macro. In particular, I need to better understand how to produce the lower two or three section bars to a particular specification.
I would like each of the three 'markers' to be in a REGULAR typeface, whilst the section header text itself remains emphasised strongly (i.e bold). I have partially achieved this effect for the second section bar. N.b. Document's default roman typeface is Gill Sans Light (see lipsum par.), whilst Gill Sans (Regular) is set as
mainfont
.I would like the section header text to properly align left, i.e. as normal text and first two section headers.
I am aware that my definition of the new commands
\ssection
and\tsection
is poor. Although they work, I suspect that I have not achieved this "appropriately"—though I'm not sure why.
If anyone can go further, I would ideally like to reverse the section bars with markers, by placing the markers on the left of the page, with section header text flushright
. When I experimented with doing this directly, by inserting this command into the \titleformat
command, it moved everything in a manner that was beyond me to develop usefully. Perhaps there are other ways of using tikz (styles?) that would be more efficient. But perhaps this should be the topic of a separate question…?
A MWE follows.
Note: it incorporates a couple of options (using toggle), which allow for an handbook option (fh), in which ALL section headers are unnumbered and a French translation option (fr), both of which are set to false
in this example. I recognise that this is therefore not technically a minimum working example, but hope you are able to indulge me, since removing the toggles would require redefining integral elements of the macro.
With appreciation for assistance and advice given.
\documentclass[a5paper, openany]{memoir}
\usepackage{fontspec} % glurl.co/fs0
\setmainfont[Ligatures=TeX]{Gill Sans}
\setromanfont[Ligatures=TeX]{Gill Sans Light}
\setlrmarginsandblock{0.85in}{0.85in}{*}
\usepackage{lipsum}
\usepackage{etoolbox}
\newtoggle{fr}
\newtoggle{fh}
\togglefalse{fr} % english
\togglefalse{fh} % module handbook
\usepackage[usenames,dvipsnames]{xcolor}
\definecolor {bar} {gray}{0.7}
\definecolor {marker} {named}{black}
% section bar headings defined, using tikz
\usepackage[explicit]{titlesec} % glurl.co/dFH
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\makeatletter
\let\currentsectiontitle\relax
\newcommand\sectionbar{
\tikz[baseline,trim left=\trim,trim right=\trim] {
\fill [\barfill] (2.25cm,-1ex) rectangle (\textwidth+3cm,2.5ex);
\node [ fill=\markerfill, anchor= base east, rounded rectangle,
minimum height=3.5ex] at
(13.8cm,{\vertical+\vadjust}) {\sectionmarker};
\node [ fill=\barfill, anchor= base east, rounded rectangle,
minimum height=3.5ex] at
(\markerinset,\vertical) {};
}}
\def\sectionmarker{}
\def\barfill{bar}
\def\markerfill{bar}
\def\trim{2.8cm}
\def\vertical{0.1435}
\def\vadjust{0}
\def\markerinset{2.6cm}
\iftoggle{fh}{
\titleformat{name=\section,numberless} % http://glurl.co/e7H
{\large\bfseries}{\sectionbar}
{0.1cm}{\gdef\currentsectiontitle{#1}#1}
}{
\iftoggle{fr}{
\def\@@topic{Th\`eme}
\def\@@summary{R\'esum\'e}
\def\@@topicsummary{R\'esum\'e du Th\`eme}
}{
\def\@@topic{Topic}
\def\@@summary{Summary}
\def\@@topicsummary{topic summary}
}
\newcommand\@sectionbar{
\def\trim{3.5cm}
\def\vadjust{-0.0875}
\def\markerfill{marker}
\sectionbar}
\newcommand\@topic{
\def\sectionmarker{\color{white}{\space \@@topic \space \thesection}}
\@sectionbar}
\newcommand\@summary{
\def\sectionmarker{\color{white}{\@@summary}}
\@sectionbar}
\newcommand\@topicsummary{
\def\sectionmarker{\color{white}{\@@topicsummary}}
\@sectionbar}
\newcommand\titlebar{\@ifstar\sectionbar\@topic}
\titleformat
{\section}
{\large} % \flushright, \raggedleft
{\titlebar}
{-0.68cm}
{\bfseries\gdef\currentsectiontitle{#1}#1}
\renewcommand* {\thesection} {\arabic{section}}
\newcommand {\osection}[1] {\section*{\sectionbar#1}}
\newcommand {\ssection}[1] {\section*{\@summary#1}}
\newcommand {\tsection}[1] {\section*{\@topicsummary#1}}
}%end-toggle
\makeatother
\begin{document}
\chapter{Title}
\label{title}
\osection{Terms used in this study}
\label{termsusedinthisstudy}
\section{First section}
\label{firstsection}
\tsection{Topic summarised}
\label{topicsummarised}
\ssection{Study 1 Summarised}
\label{study1summarised}
\lipsum[1]
\end{document}