LaTeX forum ⇒ Text FormattingIssue with aligning of words in chemfig environement

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Czajnik166
Posts: 6
Joined: Tue Jun 04, 2019 9:05 pm

Issue with aligning of words in chemfig environement

Postby Czajnik166 » Tue Jun 04, 2019 9:24 pm

Hello all! I've been a happy latex user for some time. I always came to the forum to take some help, but this time I can not find a solution to a problem that torments me. Hence the question to you:
I use \chemfig package for printing arrow with some text/graph above/below. When I write a word that has: j, y, p, g, q it is aligned with this local letter - and I would like words to be globally equated, is there any solution? There is no problem in the text as far.
Code for an example:
\schemestart
\textbf{Mesh}\arrow{->}[0, 0.5]\textbf{Import Mesh}\arrow{->}[0, 0.2]\textbf{ICEM CFD}
\schemestop \newline
All "Import Mesh" is a bit higher then the rest. Could some one help me with this?

User avatar
Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Wed Jun 05, 2019 7:21 am

Can you please make a complete example that we can test right away?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Czajnik166
Posts: 6
Joined: Tue Jun 04, 2019 9:05 pm

Postby Czajnik166 » Thu Jun 06, 2019 4:20 pm

Sure, pleas find it below
\documentclass[a4paper,11pt]{report}
\linespread{1.5} % interlinia
\usepackage{latexsym}
\usepackage[justification=centerlast,font=small]{caption}%do podpisów rysunków i tabel
\usepackage{microtype}
\usepackage{ulem}
\usepackage[OT4]{fontenc} %T1 lub OT4
\usepackage[polish]{babel}
\usepackage[utf8]{inputenc}
%\usepackage{amssymb}
\usepackage{graphicx} % for improved inclusion of graphics
\usepackage{epstopdf}
\usepackage{indentfirst} % wstawia wciecie w pierwszym akapicie rozdziału
\newcommand{\graph}{\includegraphics[scale=0.02]{example-image}}



\usepackage{paralist}
\usepackage{lipsum}
\usepackage{chemfig}


\begin{document}

\chapter{Introduction}
\lipsum[1]
\begin{enumerate}
\item This it the first good and aligned example\\
\schemestart
File \arrow{->[\graph]}[0, 0.5]Save case as...
\schemestop\newline
\item Second, not aligned\\
\schemestart
File \arrow{->[\graph]}[0, 0.5]Probably\arrow{->}[0, 0.5]It is not\arrow{->[\graph]}[0, 0.5]Aligned
\schemestop\newline
\end{enumerate}

\lipsum[2]
\end{document}

Czajnik166
Posts: 6
Joined: Tue Jun 04, 2019 9:05 pm

Postby Czajnik166 » Mon Jun 10, 2019 1:03 pm

Up. Is there anyone who can solve this issue?

kaiserkarl13
Posts: 636
Joined: Tue Mar 25, 2008 5:02 pm

Postby kaiserkarl13 » Tue Jun 11, 2019 5:38 am

It's a function of where the arrows are anchored. In this case, the defaults are (.east--.west), but the text is vertically centered on the entire letter, not on the baseline, so you're getting what looks like misalignment. You can use \arrow(.base east--.base west) to get the base lines aligned, but that puts the arrows at the bottom instead of the center. See section 5 of the chemfig documentation for more information about anchors.

Czajnik166
Posts: 6
Joined: Tue Jun 04, 2019 9:05 pm

Postby Czajnik166 » Tue Jun 11, 2019 6:00 pm

thank you for your answer.
The presentation contains some useful information that helped me solve my other problems.
Aligning the line to the bottom is a good solution, but not a solution that satisfies me ... in some cases which i use is even worse then before...but if I add an hidden character such as: y, p, g? it would help ad hoc maybe

Czajnik166
Posts: 6
Joined: Tue Jun 04, 2019 9:05 pm

Postby Czajnik166 » Tue Jun 11, 2019 9:30 pm

As i suppose, \phantom{j} do the job :mrgreen: . Not quite an elegant solution, but always some :twisted: . Subject to be closed


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 6 guests