Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement \makebox and \framebox; re-implement \fbox. #45

Merged
merged 3 commits into from
Nov 2, 2020

Conversation

cspiel
Copy link
Contributor

@cspiel cspiel commented Oct 19, 2020

Add \makebox[WIDTH][ALIGN]{TEXT} and \framebox[WIDTH][ALIGN]{TEXT}
with most of their LaTeX functionality. Base the new definition
of \fbox on \framebox. Alignment type s is unimplemented.

Macro \mbox is not touched.

Here is a demo-document:

\documentclass{article}

\usepackage{hevea}

\newenvironment{markerbar}{\begingroup$|$}{$|$\endgroup}

\begin{document}
\section{Text Mode}

\begin{itemize}
\item \texttt{\textbackslash mbox}:
  \mbox{typeset text in LR-mode};

\item \texttt{\textbackslash makebox}
  \begin{itemize}
  \item without optional arguments:
    \begin{markerbar}\makebox{text in LR-mode}\end{markerbar};
  \item with fixed width:
    \begin{markerbar}\makebox[12em]{text in LR-mode}\end{markerbar};
    \begin{markerbar}\makebox[12em][c]{text in LR-mode}\end{markerbar};
  \item fixed width, left-aligned:
    \begin{markerbar}\makebox[12em][l]{text in LR-mode}\end{markerbar};
  \item fixed width, right-aligned:
    \begin{markerbar}\makebox[12em][r]{text in LR-mode}\end{markerbar};
  \item fixed width, too wide:
    \begin{markerbar}\makebox[1em]{CENTERED}\end{markerbar};
  \item fixed width, too wide, left-aligned:
    \begin{markerbar}\makebox[1em][l]{LEFT-ALIGNED}\end{markerbar};
  \item fixed width, too wide, right-aligned:
    \begin{markerbar}\makebox[1em][r]{RIGHT-ALIGNED}\end{markerbar};
  \end{itemize}

\item \texttt{\textbackslash fbox}:
  \fbox{typeset text in LR-mode and frame it};

\item \texttt{\textbackslash framebox}
  \begin{itemize}
  \item without optional arguments: \framebox{text in LR-mode};
  \item with fixed width: \framebox[12em]{text in LR-mode};  \framebox[12em][c]{text in LR-mode};
  \item fixed width, left-aligned: \framebox[12em][l]{text in LR-mode};
  \item fixed width, right-aligned: \framebox[12em][r]{text in LR-mode};
  \item fixed width, too wide: \framebox[1em]{CENTERED};
  \item fixed width, too wide, left-aligned: \framebox[1em][l]{LEFT-ALIGNED};
  \item fixed width, too wide, right-aligned: \framebox[1em][r]{RIGHT-ALIGNED};
  \end{itemize}
\end{itemize}


\section{Framebox Nesting}

\begin{itemize}
\item \texttt{\textbackslash fbox}:
  \fbox{E\fbox{F\fbox{G\fbox{H\fbox{I\fbox{J\fbox{K\fbox{L\fbox{M}N}O}P}Q}R}S}T}U}

\item \texttt{\textbackslash framebox}:
  \framebox{E\framebox{F\framebox{%
        G\framebox{H\framebox{I\framebox{%
              J\framebox[9em][l]{K\framebox[5em][r]{L\framebox[2em][c]{M}N}O}P%
            }Q}R}S%
      }T}U}
\end{itemize}


\section{Math Mode}

Check whether \texttt{\textbackslash normalfont} works inside of a
math environment:
$r_{\mathrm{s}} c^2 = 2 G M\textnormal{ with Schwarzschild radius}~r_{\mathrm{s}}$.

\begin{equation}
    E = \hbar \omega\quad\makebox{de~Broglie}\ \mbox{I}
\end{equation}

\[
    p = \hbar k\quad\framebox{de~Broglie}\ \fbox{II}
\]

\begin{eqnarray}
  E  &  =  &
  \frac{p^2}{2m}  \\
  E  &  \rightarrow  &
  i \hbar \frac{\partial}{\partial{}t}\ \framebox{N.~Bohr}, \makebox{M.~Planck: $\hbar$}  \\
  p  &  \rightarrow  &
  -i \hbar \frac{\partial}{\partial{}x}\ \framebox{N.~Bohr}, \makebox{M.~Planck: $\hbar$}  \\
  -\frac{1}{2m} \frac{\partial^2}{\partial{}x^2} \Psi(x, t)  &  =  &
  i \frac{\partial}{\partial{}t}\Psi(x, t)\quad\makebox{Schr\"odinger Equ.}
\end{eqnarray}
\end{document}

Please compare the rendering of LaTeX to the Hevea output. Overprinting effects of
the demo will look ugly. This is intentional as we test whether the HTML output
strictly keeps the text baselines even and obeys the ALIGN specifiers where they stack
up against the default left-to-right direction.

Add \makebox[WIDTH][ALIGN]{TEXT} and \framebox[WIDTH][ALIGN]{TEXT}
with most of their LaTeX functionality.  Base new definition
of \fbox on \framebox.

Alignment type `s' is unimplemented.
@cspiel
Copy link
Contributor Author

cspiel commented Nov 2, 2020

As chapter C.12.3 "Boxes" of the LaTeX Reference Manual is open
I'd like to add \raisebox and \parbox.

\documentclass{article}

\usepackage{hevea}

\newcommand*{\samplephrase}{The quick brown fox jumps over the lazy
  dog.  Heavy boxes per\-form quick waltzes and jigs.  Sphinx of black
  quartz, judge my vow!}

\begin{document}
\section{Raised and Lowered Boxes}

\begin{itemize}
\item Some \raisebox{0.25em}{raised} text
\item and also some \raisebox{-0.125em}{lowered} text.
\item Again \raisebox{1.5em}[1pt]{raised (ht)} text, but with
  artificial height
\item and \raisebox{-0.25em}[2pt][0pt]{lowered (ht, dp)} text
  with artificial height and depth.
\end{itemize}

\section{Parboxes}

Parbox w/o optional parameter.\quad\parbox{14em}{\samplephrase}

\noindent Bottom-aligned parbox.\quad\parbox[b]{14em}{\samplephrase}

\noindent Top-aligned parbox.\quad\parbox[t]{14em}{\samplephrase}

\noindent \parbox{10em}{\samplephrase}\quad
Some funny stuff.\quad\parbox{10em}{\samplephrase}
\end{document}

Again, the overprinting effects are intentional.

@maranget
Copy link
Owner

maranget commented Nov 2, 2020

It looks good, thanks again for your work on hevea.

I merge. There is a small problem as the tutorial uses \raisebox as an example of a non-implemented macro!
I'll correct this this evening. I'd also like to include your two examples in the example web page, with credit to you. Do you agree?

@maranget maranget merged commit 116e3fc into maranget:master Nov 2, 2020
@cspiel
Copy link
Contributor Author

cspiel commented Nov 2, 2020

@maranget: LOL! I was so busy implementing \raisebox
that I did not notice it is documented as unimplemented.

WRT the examples, you can go ahead and include them.

As a reminder for the future when we shall have dimensions
(aka "lengths") macro \raisebox will need some touchup.
The LaTeX original allows to set both, height and depth
separately and IMO, we ought to map that to the sum of
both in the CSS box model.

@cspiel cspiel deleted the makebox-framebox branch November 2, 2020 09:02
@maranget
Copy link
Owner

maranget commented Nov 2, 2020

@cspiel I cannot find a simple example of a latex command that hevea does not implement. If you have some idea to change this section of the manual.

At the moment, I'll simply state that \raisebox now is implemented, the method illustrated by the outdated examples still being worth considering.

@cspiel
Copy link
Contributor Author

cspiel commented Nov 2, 2020

@maranget: Right now, I don't know of a good example either!
However, I'd follow your suggestion and keep the \raisebox example;
it is well elaborated and easy to grasp without in-depth knowledge
if LaTeX or Hevea.

You could mention that it is impossible to implement
the exact "signature" of LaTeX's \raisebox{RAISE_LEN}[HGTH][DPTH]{TEXT}
because of the non-standard positions of the optional arguments, though.

Otherwise just introduce the example with something like
"if we did not have \raisebox, we would work around the missing macro
like this..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants