Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

example output

I want a. to be in the same line with {w | w begins ... Yesterday, I found one solution that uses some commands to set the subsection title but I can't find it today since I did not remember the command name. A reference link would be greatly appreciated. Thank you.

Minimal Example

\documentclass[10pt,letterpaper]{article}

\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry} 
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{ntheorem}
\usepackage{polynomial}
\usepackage{layouts}
\usepackage{enumerate}

\usepackage[version=0.96]{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,automata,backgrounds,petri,positioning}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{decorations.text}
\usetikzlibrary{decorations.fractals}
\usetikzlibrary{decorations.footprints}
\usetikzlibrary{shadows}

\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\usepackage[bookmarksopen,bookmarksdepth=3]{hyperref}
\usepackage{titlesec}
\usepackage{xcolor}

%define new colors
\definecolor{dark-red}{rgb}{0.4,0.15,0.15}
\definecolor{dark-blue}{rgb}{0.15,0.15,0.4}
\definecolor{medium-blue}{rgb}{0,0,0.5}

%set up color for table of contents
\hypersetup{
    colorlinks, linkcolor={medium-blue},
    citecolor={dark-blue}, urlcolor={medium-blue}
}

\usepackage{tocloft}

%title
\title{\textbf{Solution for Chapter 1}}

\begin{document}

\setlength{\cftsecnumwidth}{3em} % Set numwidth of section
\setlength{\cftsubsecnumwidth}{6em} % Make subsection numwidth the same as section
\setlength{\cftsubsecindent}{\cftsecindent} % Make subsection indent the same as section

\tableofcontents 
\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex}
\maketitle

    \phantomsection
    \section*{1.1}
    \addcontentsline{toc}{section}{\numberline{1.1}The following are the state diagrams for two DFAs, $M_1$, and $M_2$. Answer the following question 
    about each of these machines.}

    The following are the state diagrams for two DFAs, $M_1$, and $M_2$. Answer the following question 
    about each of these machines.\\

    \begin{tikzpicture}[shorten >=1pt, node distance=2cm,auto,on grid,initial text=, every state/.style={minimum size=3mm,draw=blue!50,very thick,fill=blue!20}]
        \begin{scope}
            \node[state,initial]    (q_1)                           {$q_1$}; 
            \node[state,accepting]  (q_2)   [right=of q_1]          {$q_2$}; 
            \node[state]            (q_3)   [below right=of q_1]    {$q_3$}; 

            \path[->]
            (q_1) edge  [bend left]     node {a}        (q_2)
            (q_1) edge  [loop above]    node {b}        (q_1)

            (q_2) edge  [bend left]     node {a,b}      (q_3)

            (q_3) edge  [bend left]     node {a}        (q_2)
            (q_3) edge  [bend left]     node {b}        (q_1);  
            \node [below=1cm, align=flush center,text width=8cm] at (q_3)
            {
                $M_1$
            };
        \end{scope}

        \begin{scope}[xshift=8cm]
            \node[state,initial,accepting]  (q_1)                   {$q_1$}; 
            \node[state]             (q_2)  [right=of q_1]          {$q_2$}; 
            \node[state]             (q_3)  [below=of q_1]          {$q_3$}; 
            \node[state,,accepting]  (q_4)  [below=of q_2]          {$q_4$};

            \path[->]
            (q_1) edge  [bend left]     node {a}        (q_2)
            (q_1) edge  [loop above]    node {b}        (q_1)

            (q_2) edge  [bend left]     node {a}        (q_3)
            (q_2) edge  [bend left]     node {b}        (q_4)

            (q_3) edge  [bend left]     node {b}        (q_1)
            (q_3) edge  [bend left]     node {a}        (q_2)

            (q_4) edge  [loop below]    node {b}        (q_4)
            (q_4) edge  [bend left]     node {a}        (q_3)           
            ;   
        \node [below=1cm, align=flush center,text width=8cm] at (q_3)
            {
                $M_2$
            };
        \end{scope}
    \end{tikzpicture}

    \textbf{Solution}\\

    \phantomsection 
    \subsection*{a.}
    \addcontentsline{toc}{subsection}{\numberline{}a. What is the start state?}
    What is the start state?\\
        $M_1$ start states: $q_1$\\
        $M_2$ start states: $q_1$\\

    \phantomsection         
    \subsection*{b.}
    \addcontentsline{toc}{subsection}{\numberline{}b. What is the set of accept states?}
    What is the set of accept states?\\
        $M_1$ accepting states: $q_2$\\
        $M_2$ accepting states: $q_1, q_4$\\

    \phantomsection     
    \subsection*{c.}
    \addcontentsline{toc}{subsection}{\numberline{}c. What sequence of states does the machine go through on input $aabc$}
    What sequence of states does the machine go through on input $aabc$?\\
        $M_1$: $q_1 \rightarrow q_2 \rightarrow q_3 \rightarrow q_1 \rightarrow q_1$\\
        $M_2$: $q_1 \rightarrow q_1 \rightarrow q_1 \rightarrow q_2 \rightarrow q_4$\\

    \phantomsection 
    \subsection*{d.}
    \addcontentsline{toc}{subsection}{\numberline{}d. Does the machine accept the string $aabb$?}
    Does the machine accept the string $aabb$?\\
        $M_1$: No because the last state $q_1$ is not an accepting state.\\
        $M_2$: Yes because the last state $q_4$ is an accepting state.\\

    \phantomsection 
    \subsection*{e.}
    \addcontentsline{toc}{subsection}{\numberline{}e. Does the machine accept the string $\varepsilon$?}
    Does the machine accept the string $\varepsilon$?\\
    No, both of them do not accept string $\varepsilon$.
\end{document}
share|improve this question
    
Please post a minimal working example showing how exactly you are defining your subsections. –  Gonzalo Medina Aug 2 '11 at 23:28
    
@Gonzalo Medina: Sorry, I totally forgot. Minimal example added. –  Chan Aug 2 '11 at 23:46
    
@Chan: Why do you use subsection*? You can simple redefine the counter subsection to: \renewcommand\thesubsection{\alph{subsection}}. –  Marco Daniel Nov 26 '11 at 17:19
add comment

1 Answer

up vote 7 down vote accepted

Is this post helpful?

\usepackage{titlesec}
\titleformat{\subsection}[runin]{\normalfont\bfseries}{\thesubsection.}{3pt}{}
share|improve this answer
    
Thanks a lot. This is exactly what I'm looking for. –  Chan Aug 2 '11 at 23:45
    
No problem! Don't forget to accept my answer if appropriate :) –  cmhughes Aug 2 '11 at 23:46
    
But there is beauty problem here. The text blindly starts immediately after the subsection, but later does not get left alligned, exactly along the vertical line, where the text started. How to avoid this? pls help –  user17592 Aug 14 '12 at 17:37
1  
Welcome to TeX.sx! Your question won't be seen by many people here, so it would be best to repost it as a fresh question. Follow-up questions like this are more than welcome! Please use the "Ask Question" link for your new question; there you can link to this question to provide the background. –  Gonzalo Medina Aug 14 '12 at 19:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.