# Centering within NewEnvironment

I'm working on a LaTex Class for script-writing. I've come into a problem when declaring a Dialog environment.

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{exampleclass}[2014/08/16 Example LaTeX class]

\documentclass{article}
\usepackage{amsmath}
\RequirePackage{xcolor}
\definecolor{slcolor}{HTML}{882B21}
% needed for its \numberwithin command
\newcounter{panelctr}

\renewenvironment{boxed}[1]
{\begin{center}
#1\\[1ex]
\begin{tabular}{|p{0.9\textwidth}|}
\hline\\
}
{
\\\\\hline
\end{tabular}
\end{center}
}

\newenvironment{panel}{%      define a custom environment
\bigskip\noindent%         create a vertical offset to previous material
\refstepcounter{panelctr}% increment the environment's counter
\textsc{Panel \thepanelctr}% or \textbf, \textit, ...
\newline%
}{\par\bigskip}  %          create a vertical offset to following material
\numberwithin{panelctr}{section}

\newenvironment{character}[1]
{%
\vfill
\hfill
\textbf{#1}\\
}
{

\hfill
\vfill
}%
%--------------------------------------------------

\begin{document}
Below this line a boxed environment is used

\begin{boxed}{Title of the Box}
This is the text formatted by the boxed environment
\end{boxed}

This text is again outside the environment

\section{First section}

Some text before the first algorithm environment \ldots

\begin{panel}
Some thoughts
\begin{character}{Character1}
Hello, This text is again outside the environment
\end{character}

\begin{character}{Character2}
test dialog
\end{character}
\end{panel}

\begin{panel}
More thoughts
\end{panel}

\end{document}

Currently the actual dialog doesn't seem to be centered while the characters name is centered. My idea formatting:

It was also be great if there is a way to get the Parenthetical's to align either left or right to the center of the dialog

• (1) Why are you reinventing the wheel? I'm sure the hexagonal design did well when you consulted the focus groups, but are you sure the tried and tested circular shape will not continue to sell better? (2) Never use \\ to break lines outside of special contexts (tabular, array etc.). (3) Please always post minimal, but complete, code we can copy-paste-compile. (4) Please upload your image in the editor rather than relying on an external link. – cfr Jun 14 '17 at 0:59
• I'd guess your code typesets the argument in bold on the right of the page, then typesets the contents of the environment normally, followed by a paragraph break, possibly putting space above and below. – cfr Jun 14 '17 at 1:04
• Thanks for the reply. I'm not sure what you mean by circular shape. What should be used instead of double slashes for break? – Dubb Jun 14 '17 at 1:26
• Didn't realize I was re-inventing the wheel, I'm trying to minimize the commands needed for the actual Tex document. – Dubb Jun 14 '17 at 1:32
• Unrelated to what you are asking, but \documentclass{article} \usepackage{amsmath} inside a class file?!? In case you are requiring the amsmath package just to use the \numberwithin command, forget it and simply say \newcounter{panelctr}[section]. – GuM Jun 14 '17 at 2:02

Just use the screenplay document class. There are more packages and classes for this, see https://www.ctan.org/topic/drama-script

\documentclass{screenplay}
\begin{document}

\begin{dialogue}[looking up]{Joe}
And the position of the character's name?
\end{dialogue}
\begin{dialogue}{April}
ALL CAPS, and tabbed to about 4.0 to 4.2 inches, depending upon the
look you like. Some writers center al characters' name in
dialogue. Personally, I don't think it matters too much.
\end{dialogue}

\end{document}

• Wow, I searched but didn't bother to search "screenplay". Thanks – Dubb Jun 14 '17 at 3:51