3

I'm trying to make a note book on LaTeX for a language course. For this I sort my vocabulary lists by theme. As you can see in the example below, I use a \hfill inside the \subsection command to make the title of the theme in the two language.

\documentclass[oneside]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T5]{fontenc}
\usepackage{tikz}
\usepackage{geometry}

\geometry{a5paper}

\usepackage{titletoc}
\usepackage{titlesec}

%command to print the acutal minitoc
\newcommand{\printmyminitoc}{
        \setcounter{tocdepth}{2} 
        \begin{center}\begin{tikzpicture}
            \node[rounded corners,align=left,fill=black]{%
        \color{white}%
        \begin{minipage}{10cm}%minipage trick
        \noindent\printcontents[chapters]{}{1}{}
        \end{minipage}};
    \end{tikzpicture}\end{center}
        }


\begin{document}


\chapter{Giới thiệu \hfill Se pr\'esenter }

\startcontents[chapters]
\printmyminitoc


\section{Vocabulaire - Từ ngữ}

\subsection{Nghề nghiệp \hfill Profession}

\noindent Bác sĩ \hfill Médecin\\
Y tá \hfill Infirmier\\
Luật sư \hfill Avocat\\
Kỹ sư \hfill Ingénieur

\subsection{Nơi làm việc \hfill Lieu de travail}

\noindent Bệnh viện \hfill Hôpital\\
Tòa án \hfill Cours de Justice\\
Trường đại học \hfill Université\\
Ngân hàng \hfill Banque


\end{document}

Since the size of my notes are increasing pretty much, I tried to use mini Table of Contents at the beginning of each chapter. I found out a code on the internet, but as you can see, the result isn't really satisfying because of \hfill.

I wondered if it was possible to create a command \subsection which take two arguments instead of one. e.g. \subsection{Nghe nghiep}{Profession}. It would show me the same result when I begin a subsection but in the mini-ToC, it should take and show only the first or the second argument.

Also, in this mini-ToC, the margin is different on the left and the right, how can I do to increase the margin to the right or remove the indentation to the left?

I'm open to solutions that gives me a nicer mini-ToC.

4

You can use the optional argument like \subsection[Nghề nghiệp]{Nghề nghiệp \hfill Profession}. For adjusting the margins use \hspace*{-1.6pc} just before minipage and make node's width equal to text width.

\documentclass[oneside]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T5]{fontenc}
\usepackage{tikz}
\usepackage{geometry}

\geometry{a5paper}

\usepackage{titletoc}
\usepackage{titlesec}

%command to print the acutal minitoc
\newcommand{\printmyminitoc}{
        \setcounter{tocdepth}{2}
        \begin{center}
        \begin{tikzpicture}
            \node[rounded corners,align=left,fill=black,minimum width=\textwidth]{%
        \color{white}%
        \hspace*{-1.6pc}
        \begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}%minipage trick
        \printcontents[chapters]{}{1}{}
        \end{minipage}%
        };
      \end{tikzpicture}
       \end{center}%
        }


\begin{document}


\chapter[Giới thiệu]{Giới thiệu \hfill Se pr\'esenter }

\startcontents[chapters]
\printmyminitoc


\section{Vocabulaire - Từ ngữ}

\subsection[Nghề nghiệp]{Nghề nghiệp \hfill Profession}

\noindent Bác sĩ \hfill Médecin\\
Y tá \hfill Infirmier\\
Luật sư \hfill Avocat\\
Kỹ sư \hfill Ingénieur

\subsection[Nơi làm việc]{Nơi làm việc \hfill Lieu de travail}

\noindent Bệnh viện \hfill Hôpital\\
Tòa án \hfill Cours de Justice\\
Trường đại học \hfill Université\\
Ngân hàng \hfill Banque


\end{document}

enter image description here

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.