Text FormattingIssue with aligning of words in chemfig environement

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

Issue with aligning of words in chemfig environement

Post by Czajnik166 »

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?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Issue with aligning of words in chemfig environement

Post by Johannes_B »

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

Issue with aligning of words in chemfig environement

Post by Czajnik166 »

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

Issue with aligning of words in chemfig environement

Post by Czajnik166 »

Up. Is there anyone who can solve this issue?
kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Issue with aligning of words in chemfig environement

Post by kaiserkarl13 »

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

Issue with aligning of words in chemfig environement

Post by Czajnik166 »

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

Issue with aligning of words in chemfig environement

Post by Czajnik166 »

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