Method and device for typesetting and displaying formulas in document and electronic equipment

By performing line-breaking typesetting processing based on formula unit integrity of the target formula in the document, the difficulties in debugging, reading and understanding of complex formulas are solved, and the efficiency of judging the accuracy of formulas is improved.

CN119623413APending Publication Date: 2025-03-14ZHUHAI KINGSOFT OFFICE SOFTWARE +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411675517.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

During the use of formulas, there are many characters in complex formulas, and there is no obvious difference between different functions and parameters, which leads to difficulties in debugging, reading, understanding the meaning of formulas, and it is difficult to judge whether the formulas in the document are accurate.

Method used

By obtaining the target formula in the document and performing line-breaking typesetting according to the integrity of the formula unit, ensure that the formula unit in the subformula is a complete unit, and then displaying the formatted formula.

Benefits of technology

It improves the efficiency of determining whether the formula in the document is accurate, simplifies the process of editing, debugging, reading and understanding of the formula, and reduces the loss of equipment resources caused by repeated adjustments to the formula.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119623413A_ABST
    Figure CN119623413A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to a typesetting and displaying method and device for formulas in a document and electronic equipment. The method comprises the steps that a target formula in the document is obtained; according to the completeness of the formula units, the target formula is subjected to line feed typesetting processing to obtain a typeset formula, and under the condition that sub-formulas of the typeset formula comprise the formula units, the formula units in the sub-formulas are complete units; and displaying the typeset formula. Therefore, the target formula can be displayed hierarchically, the composition of the target formula can be efficiently determined, and the integrity of the formula unit in the target formula can be efficiently determined, so that the efficiency of determining whether the target formula in the document is accurate or not can be improved in the aspects of editing, debugging, reading and understanding of the target formula, and the accuracy of the target formula is improved. And equipment resource loss caused by repeated adjustment of the target formula is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of document processing, and in particular to a method, device and electronic device for typesetting and displaying formulas in a document. Background Art

[0002] In the related art, when using formulas, it is common to combine multiple functions into nested formulas. Complex formulas have many characters and no clear distinction between different functions and parameters, which makes it difficult to debug, read, and understand the meaning of formulas.

[0003] Furthermore, the existence of the above difficulties makes it difficult to determine whether the formula in the document is accurate. Users and other objects often need to spend a lot of time to check the formula. It can be seen that how to improve the efficiency of determining whether the formula in the document is accurate is a technical issue worthy of attention. Summary of the invention

[0004] In view of this, in order to solve some or all of the above-mentioned technical problems, an embodiment of the present application provides a method, device and electronic device for typesetting and displaying formulas in a document.

[0005] In a first aspect, an embodiment of the present application provides a method for typesetting and displaying a formula in a document, the method comprising:

[0006] Get the target formula in the document;

[0007] According to the integrity of the formula unit, the target formula is subjected to line break typesetting processing to obtain a typeset formula, wherein, in the case where a sub-formula of the typeset formula includes the formula unit, the formula unit in the sub-formula is a complete unit;

[0008] Display the typeset formula.

[0009] In a possible implementation, performing line break typesetting processing on the target formula according to the integrity of the formula unit to obtain a typeset formula includes:

[0010] Determine the position of at least one preset character among a plurality of characters constituting the target formula to obtain a position set, wherein the preset character is used to separate complete formula units;

[0011] Determining a target line break point of the target formula based on the positions in the position set;

[0012] According to the target line break point, the target formula is subjected to line break typesetting processing to obtain a typeset formula.

[0013] In a possible implementation, determining the target line break point of the target formula based on the position in the position set includes:

[0014] For a position in the position set, the adjacent characters of the preset character at the position and the positions between the preset characters at the position in the target formula are determined as candidate points corresponding to the position; wherein the adjacent characters are: the preceding character of the preset character and / or the succeeding character of the preset character;

[0015] A target line break point of the target formula is determined from candidate points corresponding to respective positions in the position set.

[0016] In a possible implementation, determining the target line break point of the target formula from the candidate points corresponding to the respective positions in the position set includes:

[0017] For a position in the position set, based on the role of the preset character located at the position in the target formula, it is determined whether to determine the candidate point corresponding to the position as the line break point of the target formula.

[0018] In a possible implementation, displaying the typeset formula includes:

[0019] Displaying the typeset formula by a formula editor; and

[0020] The step of determining the target line break point of the target formula from the candidate points corresponding to the respective positions in the position set includes:

[0021] Determining a display width of the formula editor, wherein the formula editor is an editor for displaying the target formula;

[0022] Determine the row width of each row of sub-formulas of the target formula to obtain a row width set;

[0023] Based on the display width and the line width set, a target line break point of the target formula is determined from candidate points corresponding to respective positions in the position set.

[0024] In a possible implementation, determining the target line break point of the target formula from candidate points corresponding to respective positions in the position set based on the display width and the line width set includes:

[0025] In a case where the line width set includes a target line width greater than the display width, determining the position of a first character in a sub-formula corresponding to the target line width from the position set to obtain a first position subset, wherein the first character is a preset character of a next level of line break priority of a current line break priority corresponding to the target line width;

[0026] The candidate points corresponding to the positions in the first position subset are determined as the target line break points of the target formula.

[0027] In a possible implementation, determining the target line break point of the target formula from candidate points corresponding to respective positions in the position set based on the display width and the line width set includes:

[0028] In a case where the line width set includes a target line width greater than the display width, determining a position of a second character in the target formula from the position set to obtain a first position subset, wherein the second character is a preset character of a next level of line break priority of a current line break priority corresponding to the line width set;

[0029] The candidate points corresponding to the positions in the first position subset are determined as the target line break points of the target formula.

[0030] In a possible implementation, determining the target line break point of the target formula based on the position in the position set includes:

[0031] In the case where the target formula includes nested formula units, determining the line break priority of each preset character at each nested level in the nested formula units in the sub-formula; wherein the line break priority of each preset character in a single or multiple formula units at the same nested level is the same; and the line break priority of each preset character in a formula unit at an outer nested level is higher than the line break priority of each preset character in a formula unit at an inner nested level;

[0032] From the position set, determine the position of a preset character whose line break priority is higher than the target priority to obtain a second position subset;

[0033] A position in the second position subset is determined as a target line break point of the target formula.

[0034] In a possible implementation, the document includes a table, and the table includes cells; and

[0035] The method further comprises:

[0036] Using the target formula or the typeset formula as a display formula, and displaying the display formula;

[0037] In the process of editing the display formula, receiving a selection operation on a cell in the table;

[0038] In response to the selection operation, adjusting the display formula using the address of the cell, the formula in the cell, or the calculation result of the formula in the cell to obtain an updated formula;

[0039] The updated formula is displayed.

[0040] In a possible implementation, after displaying the typeset formula, the method further includes:

[0041] In response to a selection operation on a sub-formula in the typeset formula, receiving an operation of adding a content annotation to the sub-formula;

[0042] Displays the added content annotation.

[0043] In a possible implementation, before receiving the operation of adding a content annotation to the sub-formula, the method further includes:

[0044] Establishing an association relationship between the sub-formula and the content annotation;

[0045] The displaying of the typeset formula includes:

[0046] Determine the sub-formula of each row in the typeset formula;

[0047] In a case where it is determined based on the association relationship that the sub-formula is associated with a content annotation, the content annotation associated with the sub-formula is displayed.

[0048] In a possible implementation, after displaying the typeset formula, the method further includes:

[0049] In response to a target operation on a formula cell in the typeset formula, a calculation result of the formula cell is displayed.

[0050] In a second aspect, an embodiment of the present application provides a device for typesetting and displaying formulas in a document, the device comprising:

[0051] A first acquisition unit, used for acquiring a target formula in a document;

[0052] A first line break unit, configured to perform line break typesetting processing on the target formula according to the integrity of the formula unit to obtain a typeset formula, wherein, when a sub-formula of the typeset formula includes the formula unit, the formula unit in the sub-formula is a complete unit;

[0053] The first display unit is used to display the typeset formula.

[0054] In a possible implementation, performing line break typesetting processing on the target formula according to the integrity of the formula unit to obtain a typeset formula includes:

[0055] Determine the position of at least one preset character among a plurality of characters constituting the target formula to obtain a position set, wherein the preset character is used to separate complete formula units;

[0056] Determining a target line break point of the target formula based on the positions in the position set;

[0057] According to the target line break point, the target formula is subjected to line break typesetting processing to obtain a typeset formula.

[0058] In a possible implementation, determining the target line break point of the target formula based on the position in the position set includes:

[0059] For a position in the position set, the adjacent characters of the preset character at the position and the positions between the preset characters at the position in the target formula are determined as candidate points corresponding to the position; wherein the adjacent characters are: the preceding character of the preset character and / or the succeeding character of the preset character;

[0060] A target line break point of the target formula is determined from candidate points corresponding to respective positions in the position set.

[0061] In a possible implementation, determining the target line break point of the target formula from the candidate points corresponding to the respective positions in the position set includes:

[0062] For a position in the position set, based on the role of the preset character located at the position in the target formula, it is determined whether to determine the candidate point corresponding to the position as the line break point of the target formula.

[0063] In a possible implementation, displaying the typeset formula includes:

[0064] Displaying the typeset formula by a formula editor; and

[0065] The step of determining the target line break point of the target formula from the candidate points corresponding to the respective positions in the position set includes:

[0066] Determining a display width of the formula editor, wherein the formula editor is an editor for displaying the target formula;

[0067] Determine the row width of each row of sub-formulas of the target formula to obtain a row width set;

[0068] Based on the display width and the line width set, a target line break point of the target formula is determined from candidate points corresponding to respective positions in the position set.

[0069] In a possible implementation, determining the target line break point of the target formula from candidate points corresponding to respective positions in the position set based on the display width and the line width set includes:

[0070] In a case where the line width set includes a target line width greater than the display width, determining the position of a first character in a sub-formula corresponding to the target line width from the position set to obtain a first position subset, wherein the first character is a preset character of a next level of line break priority of a current line break priority corresponding to the target line width;

[0071] The candidate points corresponding to the positions in the first position subset are determined as the target line break points of the target formula.

[0072] In a possible implementation, determining the target line break point of the target formula from candidate points corresponding to respective positions in the position set based on the display width and the line width set includes:

[0073] In a case where the line width set includes a target line width greater than the display width, determining a position of a second character in the target formula from the position set to obtain a first position subset, wherein the second character is a preset character of a next level of line break priority of a current line break priority corresponding to the line width set;

[0074] The candidate points corresponding to the positions in the first position subset are determined as the target line break points of the target formula.

[0075] In a possible implementation, determining the target line break point of the target formula based on the position in the position set includes:

[0076] In the case where the target formula includes nested formula units, determining the line break priority of each preset character at each nested level in the nested formula units in the sub-formula; wherein the line break priority of each preset character in a single or multiple formula units at the same nested level is the same; and the line break priority of each preset character in a formula unit at an outer nested level is higher than the line break priority of each preset character in a formula unit at an inner nested level;

[0077] From the position set, determine the position of the preset character whose line break priority is higher than the target priority to obtain a second position subset;

[0078] A position in the second position subset is determined as a target line break point of the target formula.

[0079] In a possible implementation, the document includes a table, and the table includes cells; and

[0080] The device also includes:

[0081] A second display unit, used to use the target formula or the typeset formula as a display formula and display the display formula;

[0082] A first receiving unit, configured to receive a selection operation on a cell in the table during editing of the display formula;

[0083] an adjusting unit, configured to adjust the displayed formula using the address of the cell, the formula in the cell, or the calculation result of the formula in the cell in response to the selection operation to obtain an updated formula;

[0084] The third display unit is used to display the updated formula.

[0085] In a possible implementation, after displaying the typeset formula, the device further includes:

[0086] A second receiving unit, configured to receive an operation of adding a content annotation to a sub-formula in the typeset formula in response to a selection operation on the sub-formula;

[0087] The fourth display unit is used to display the added content annotation.

[0088] In a possible implementation manner, before receiving the operation of adding a content annotation to the sub-formula, the apparatus further includes:

[0089] an associating unit, used to establish an associative relationship between the sub-formula and the content annotation;

[0090] The displaying of the typeset formula includes:

[0091] Determine the sub-formula of each row in the typeset formula;

[0092] In a case where it is determined based on the association relationship that the sub-formula is associated with a content annotation, the content annotation associated with the sub-formula is displayed.

[0093] In a possible implementation, after displaying the typeset formula, the device further includes:

[0094] The fifth display unit is used to display the calculation result of the formula cell in response to the target operation on the formula cell in the typeset formula.

[0095] In a third aspect, an embodiment of the present application provides an electronic device, including:

[0096] Memory for storing computer programs;

[0097] A processor is used to execute a computer program stored in the memory, and when the computer program is executed, it implements the method of any embodiment of the method for typesetting and displaying formulas in a document of the first aspect of the present application.

[0098] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method of any embodiment of the method for typesetting and displaying formulas in a document of the first aspect described above is implemented.

[0099] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer-readable code. When the computer-readable code is executed on a device, the processor in the device implements a method as in any embodiment of the method for typesetting and displaying formulas in a document of the first aspect mentioned above.

[0100] The method for typesetting and displaying formulas in a document provided in an embodiment of the present application can obtain a target formula in a document, and then, based on the integrity of the formula unit, perform typesetting processing on the target formula with line breaks to obtain a typeset formula, wherein, in the case where a sub-formula of the typeset formula includes the formula unit, the formula unit in the sub-formula is a complete unit, and then the typeset formula is displayed. Thus, the target formula can be displayed hierarchically, the composition of the target formula can be efficiently determined, and the integrity of the formula unit in the target formula can be efficiently determined, thereby improving the efficiency of determining the relationship between the formula units in the target formula in the document, thereby, in terms of editing, debugging, reading, and understanding the target formula, it is beneficial to improve the efficiency of determining whether the target formula in the document is accurate, and avoid the loss of equipment resources caused by repeated adjustments to the target formula. BRIEF DESCRIPTION OF THE DRAWINGS

[0101] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0102] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0103] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0104] Figure 1 A schematic diagram of a flow chart of a method for typesetting and displaying formulas in a document provided in an embodiment of the present application;

[0105] Figure 2 A flowchart of another method for typesetting and displaying formulas in a document provided in an embodiment of the present application;

[0106] Figure 3A-3D A schematic diagram of typeset formulas corresponding to different display widths in a method for typeset and displaying formulas in a document provided in an embodiment of the present application;

[0107] Figure 3E-3J A schematic diagram of an application scenario of a method for typesetting and displaying formulas in a document provided in an embodiment of the present application;

[0108] Figure 3K A schematic diagram of a display method for calculation results of a method for typesetting and displaying formulas in a document provided in an embodiment of the present application;

[0109] Figure 3L A schematic diagram of another display method of the calculation results of a method for typesetting and displaying formulas in a document provided in an embodiment of the present application;

[0110] Figure 4 A schematic diagram of the structure of a device for typesetting and displaying formulas in a document provided in an embodiment of the present application;

[0111] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0112] Various exemplary embodiments of the present application will now be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. It should be noted that unless otherwise specifically stated, the relative arrangement of the components and steps, the numerical expressions and the numerical values ​​described in these embodiments do not limit the scope of the present application.

[0113] Those skilled in the art will understand that the terms "first" and "second" in the embodiments of the present application are only used to distinguish between different steps, devices, modules and other objects, and do not represent any specific technical meanings, nor do they indicate the logical order between them.

[0114] It should also be understood that in this embodiment, “plurality” may refer to two or more than two, and “at least one” may refer to one, two or more than two.

[0115] It should also be understood that any component, data or structure mentioned in the embodiments of the present application can generally be understood as one or more, unless explicitly limited or otherwise indicated in the context.

[0116] In addition, the term "and / or" in this application is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this application generally indicates that the associated objects before and after are in an "or" relationship.

[0117] It should also be understood that the description of the various embodiments in this application focuses on the differences between the various embodiments, and the same or similar aspects thereof can be referenced to each other, and for the sake of brevity, they will not be described one by one.

[0118] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present application, its application, or uses.

[0119] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the above-mentioned technologies, methods, and equipment should be considered as part of the specification.

[0120] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.

[0121] It should be noted that, in the absence of conflict, the embodiments in this application and the features in the embodiments can be combined with each other. To facilitate the understanding of the embodiments of the present application, the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0122] In order to solve the technical problem in the prior art of how to improve the efficiency of determining whether the formulas in a document are accurate, the present application provides a method, device and electronic device for typesetting and displaying formulas in a document, which can improve the efficiency of determining whether the formulas in a document are accurate.

[0123] Figure 1 A flow chart of a method for typesetting and displaying formulas in a document provided for an embodiment of the present application. This method can be applied to one or more electronic devices such as smart phones, laptops, desktop computers, portable computers, servers, etc. In addition, the execution subject of this method can be hardware or software. When the above-mentioned execution subject is hardware, the execution subject can be one or more of the above-mentioned electronic devices. For example, a single electronic device can execute this method, or multiple electronic devices can cooperate with each other to execute this method. When the above-mentioned execution subject is software, this method can be implemented as multiple software or software modules, or as a single software or software module. It is not specifically limited here.

[0124] like Figure 1 As shown, the method specifically includes:

[0125] Step 101, obtaining a target formula in a document.

[0126] In this embodiment, the document may be any document containing a formula. As an example, the document may include but is not limited to documents in the following formats: doc format, docx format, xlsx format, xls format, ppt format, pptx format, rtf (Rich Text Format) and html (Hyper Text Markup Language) format, etc. In addition, the document may also be an offline document stored locally, or an online document stored in the cloud.

[0127] The target formula can be any formula in the above document. In practice, a user or other object can make the formula editable by clicking on the formula in the document. When the formula is editable, the formula can be used as the target formula. In addition, when a user or other object needs to insert a formula into a document, the formula to be inserted into the document can be used as the target formula.

[0128] In one embodiment, when the document is a spreadsheet document, the target formula is a formula in a cell.

[0129] Step 102, according to the integrity of the formula unit, the target formula is formatted by line breaks to obtain a formatted formula.

[0130] In this embodiment, when the sub-formula of the typeset formula includes the formula unit, the formula unit in the sub-formula is a complete unit. The sub-formula is a formula composed of characters typeset in the same row of the typeset formula, which belongs to part or all of the target formula and also belongs to part or all of the typeset formula. In other words, the typeset formula needs to ensure the integrity of the formula units in the same row, and a single complete formula unit (i.e., a complete unit) cannot be further divided so that different parts after division are displayed in different rows.

[0131] In the case where multiple sub-formula cells are nested in some formula cells, dividing the multiple sub-formula cells into different rows will not destroy the integrity of the sub-formula cells.

[0132] In this embodiment, the formula cell is a cell that is considered as a whole in the formula, and / or can be used to independently construct a legal formula. For example, the formula is "=SUM(AVERAGE(A1:A2), A3)", which means that the values ​​in cell A1 and cell A2 are averaged first, and then summed with the value of cell A3. Among them, the characters in the formula can be constructed into independent legal formulas "=SUM(x)", "=AVERAGE(x)", "=A1:A2", "=A3", where x is a parameter in the function, A1:A2 represents a reference to the cell area enclosed by cell address A1 to cell address A2, and the reference is to the value of the cell area, and A3 represents a reference to the cell corresponding to cell address A3, and similarly, the reference is to the value of the cell. Then, the formula cells that can be split out of the formula "=SUM(AVERAGE(A1:A2), A3)" include: "SUM()", "AVERAGE()", "A1:A2", "A3".

[0133] In one embodiment, if the formula complies with preset expression rules, the formula can be determined to be a legal formula, for example, the function name is correct, the parameters in the function are complete and the parameter types comply with the function settings, the data reference method is correct, etc.

[0134] In another embodiment, when a formula can be calculated as a value, the formula is determined to be a legal formula. Wherein, being calculable as a value means that it can be calculated as a binary value, a decimal value, a true value (true), a false value (false), and the like. For example, "=SUM(x)" is a value obtained by summing, "=AVERAGE(x)" is a value obtained by averaging, "=A1:A2" is a value obtained by referencing a cell range, and "=A3" is a value obtained by referencing a cell. "=A1>A2" is to determine whether the condition A1>A2 is established. If it is established, the value is a true value (true); if it is not established, the value is a false value (false).

[0135] Specifically, the formula cell can be the function name of a preset function in the formula, such as SUM (sum), AVERAGE (average), etc., indicating a formula cell of a function type. In addition, the formula cell can also be other content that can be calculated as a value (etc.), such as a variable, a constant, an equation, an inequality, a parameter in a function, etc.

[0136] The data reference variable is a variable quantity, which is reflected as a reference to a preset value. When the document is a table document, the data reference variable is a reference address of a cell or a cell range in the table.

[0137] Among them, constants are unchanging quantities, such as numbers, Boolean values, characters, strings, dates, etc.

[0138] Among them, equations and inequalities are expression forms used to describe quantitative relationships, and generally have comparison symbols (such as "=", ">", "<"). For example, A1>A2 is an inequality, and A1=A2 is an equality.

[0139] The parameter in the function can be any formula unit, which means that the function can be calculated according to the parameter in the function to obtain the calculation result. For example, when the parameter in the function is a function, a nested function is formed.

[0140] In some cases, some formula units can be combined into a group as a complete formula unit. For example, nested formula units can be combined into a group, such as, in a nested function, the function itself and the function as a function parameter are combined into a group as a complete formula unit. For example, formula units with an associated relationship can be combined into a group as a complete formula unit according to the meaning of the formula, such as, if the formula represents the assignment of a specific value to a temporary variable, the temporary variable and the assignment can be combined into a group as a complete formula unit.

[0141] In this embodiment, the sub-formula of the typeset formula may be all the contents displayed in any row of the typeset formula. In addition to formula units, a row of formula (i.e., a sub-formula) may also include preset characters, such as parameter separators (e.g., ","), operators (e.g., "+," "-," "×," "÷," etc.), comparison operators (e.g., "=", ">," "<," brackets (e.g., "(," ")," "{," "}," etc.).

[0142] Step 103, displaying the typeset formula.

[0143] In this embodiment, after the target formula is formatted with line breaks according to the integrity of the formula unit to obtain the formatted formula, the formatted formula can be further displayed.

[0144] In addition, the typeset formula can be displayed through the formula editor of the document, or the typeset formula can be displayed through the page area in the page used to display the document.

[0145] For example, for the target formula "=if(SUM(VLOOKUP(A1, B1:C10, 2, FLASE), 1)=10,"Correct", "Failed")", you can use "=if" as a formula in one row of the formula after typesetting (that is, a sub-formula), and use "(SUM(VLOOKUP(A1, B1:C10, 2, FLASE), 1)=10,"Correct", "Failed")" as another formula in another row of the formula after typesetting (that is, another sub-formula). Among them, the if() function is a complete formula cell, and the SUM() function is a complete formula cell. After typesetting, "if" is in the same row, so that the characters "i" are not in one row and "f" are not in another row; "SUM" is in the same row, so that the characters "S", "U", and "M" are not typeset in different rows.

[0146] In addition, different sub-formulas of the formatted formula may have the same or different indentations. For example, the indentations corresponding to different sub-formulas may be determined based on the hierarchical relationship between different sub-formulas of the formatted formula. Sub-formulas with higher hierarchies (e.g., inner nesting levels) may have more indentations than sub-formulas with lower hierarchies (e.g., outer nesting levels).

[0147] The number of the above-mentioned levels may be determined by calculation by the above-mentioned execution subject, or may be set by users and other objects. For example, users and other objects may set the number of levels by clicking the "increase level" or "decrease level" buttons.

[0148] In some optional implementations of this embodiment, the document includes a table, and the table includes cells.

[0149] On this basis, you can also perform the following steps:

[0150] The first step is to use the target formula or the typeset formula as a display formula and display the display formula.

[0151] Here, the display formula may be displayed via a formula editor of the document, or may be displayed via a page area in a page for displaying the document.

[0152] The second step is to receive a selection operation on a cell in the table during the process of editing the display formula.

[0153] The selection operation may be used to select at least one cell in the table.

[0154] The third step is to adjust the display formula in response to the selection operation using the address of the cell, the formula in the cell, or the calculation result of the formula in the cell to obtain an updated formula.

[0155] As an example, after receiving the selection operation, the address of the cell, the formula in the cell, or the calculation result of the formula in the cell may be added to the display formula to obtain an updated formula.

[0156] Among them, the above-mentioned references can be relative references, absolute references, mixed references, etc.

[0157] The fourth step is to display the updated formula.

[0158] Here, the updated formula may be displayed through a formula editor of the document, or may be displayed through a page area in a page for displaying the document.

[0159] In one embodiment, the target formula in the document and the typeset formula in the formula editor support synchronous editing, that is, it supports synchronizing the changes of the target formula in the document to the formula editor to modify the typeset formula; and / or, it supports synchronizing the changes of the typeset formula in the formula editor to the document to modify the target formula, so as to ensure the synchronization of the contents of the target formula and the typeset formula.

[0160] In addition, when writing the formatted formula into a cell, only the content related to the formula can be written, for example, content comments, line break information, calculation results, etc. can be omitted. Different commenting methods can correspond to different writing methods.

[0161] In one implementation example, when writing a formatted formula into a cell, the content irrelevant to the formula calculation in the formatted formula is deleted to obtain the formula to be written into the cell, so that the formula written into the cell is a legal formula. For example, content comments, line break information, calculation results, etc. in the formatted formula are deleted.

[0162] It can be understood that in the above optional implementation method, the target formula or the typeset formula can be adjusted by the address of the cell, the formula in the cell, or the calculation result of the formula in the cell. In this way, the manual input process is avoided and the editing efficiency of the formula can be improved.

[0163] In some optional implementations of this embodiment, after displaying the typeset formula, the following steps may also be performed:

[0164] The first step is, in response to a selection operation on a sub-formula in the typeset formula, receiving an operation of adding a content annotation to the sub-formula.

[0165] The selection operation may be used to select at least one row of sub-formulas in the formatted formula.

[0166] The second step is to display the added content annotation.

[0167] Here, the content annotation may be displayed at a preset position (eg, after the first row of sub-formulas) of at least one row of sub-formulas selected by the selection operation.

[0168] It can be understood that in the above optional implementation method, content annotations can be added to the sub-formulas in the typeset formula to clarify the processing logic of the sub-formulas. This can further improve the efficiency of determining the relationship between formula units in the formulas in the document, avoid the loss of equipment resources caused by repeated debugging and editing of the formulas, and further improve the efficiency of determining whether the formulas in the document are accurate.

[0169] In some application scenarios of the above optional implementation manner, after receiving the operation of adding a content annotation to the sub-formula, an association relationship between the sub-formula and the content annotation may also be established.

[0170] Here, the association relationship between the sub-formula and the content annotation may be established by associating and storing the sub-formula and the content annotation.

[0171] On this basis, the following method can also be used to display the typeset formula:

[0172] The first step is to determine the sub-formulas in each row of the formatted formula.

[0173] In a second step, when it is determined based on the association relationship that the sub-formula is associated with a content annotation, the content annotation associated with the sub-formula is displayed.

[0174] As an example, if the first typesetting method is used, the typesetting formula includes two rows of sub-formulas, namely sub-formula 1 "city," and sub-formula 2 "B3:B11,". Among them, sub-formula 1 is associated with content annotation 1 "city is the defined name", and sub-formula 2 is associated with content annotation 2 "This is the area corresponding to the value assigned to the name"; if the second typesetting method is used, the typesetting formula includes 1 row of sub-formulas, sub-formula 3 "city, B3:B11,". Among them, sub-formula 3 is associated with content annotation 3 "Define parameter city as an area for easy calling." Then, the typesetting formula has 3 association relationships between sub-formulas and content annotations. Then, in this scenario, if the initial layout method is the first typesetting method, the sub-formulas and content annotations can be displayed as follows:

[0175] city, / / city is the defined name

[0176] B3:B11, / / This is the area corresponding to the value assigned to the name

[0177] In some cases, for example, the font size of the above sub-formula or content annotation is reduced, or the width of the area for displaying the sub-formula and content annotation is increased, so that the formula editor has additional display space to accommodate wider formula cells, and the sub-formula and content annotation can be automatically converted to the second typesetting method for displaying the sub-formula and content annotation. For example, the sub-formula and content annotation can be displayed as follows:

[0178] city, B3: B11, / / Define the parameter city as an area for easy calling

[0179] At this point, the content comments associated with sub-formula 1 "city," and sub-formula 2 "B3:B11," are no longer displayed.

[0180] It can be understood that in the above application scenario, the content annotation associated with the sub-formula in the formatted formula can be determined and then displayed through the association relationship between the sub-formula and the content annotation. In this way, after the sub-formula in the formatted formula changes, the content annotation of the changed sub-formula can be dynamically adjusted and displayed, thereby improving the matching degree between the content annotation and the sub-formula in the formatted formula.

[0181] In some optional implementations of this embodiment, after displaying the typeset formula, the calculation result of the formula cell may be displayed in response to a target operation on the formula cell in the typeset formula.

[0182] The target operation may be used to display the calculation result of at least one of the formula units.

[0183] As an example, the target operation may be a hover operation of a mouse cursor or a selection operation.

[0184] Displaying the calculation result of the formula cell may be displaying the calculation result of the formula cell, and / or displaying the calculation results of all formula cells nested in the formula cell respectively.

[0185] The calculation result of the formula unit can be displayed at a preset position of at least one of the formula units, such as the starting display position or the middle position. Alternatively, it can also be displayed in a pop-up window at a preset position of the page for displaying the above document, or the calculation result can be displayed in a folded line. Alternatively, the calculation result can also be displayed in a bubble display mode, or by triggering a preset button.

[0186] For example, Figure 3KAs shown in the figure, the target operation is to display the calculation result of the formula cell of the VLOOKUP function (the function is used to find content by row in a table or range). In this scenario, for example, the calculation result of the VLOOKUP function can be displayed in Figure 3K The position shown is the middle position of the VLOOKUP function.

[0187] For example, Figure 3L As shown, the target operation is used to display the calculation results of all formula cells included in the VLOOKUP function. In this scenario, relative to the display grayscale of all formula cells included in the VLOOKUP function, a lower display grayscale can be used to display formula cells outside the VLOOKUP function.

[0188] The above calculation results can be binary values, decimal values, true values, false values, etc.

[0189] It can be understood that in the above optional implementation method, by displaying the calculation results of the formula cell, it can be conveniently used to quickly debug some formula cells in the target formula. The calculation results can be used to quickly determine whether the formula cell is written correctly and whether it can be calculated correctly, thereby further improving the efficiency of determining whether the target formula in the document is accurate.

[0190] It should be noted that, in the absence of conflict, the technical features recorded in different optional implementations may be included in the same embodiment, and for the sake of brevity, they are not repeated here.

[0191] The method for typesetting and displaying formulas in a document provided in an embodiment of the present application can obtain a target formula in a document, and then, based on the integrity of the formula unit, perform typesetting processing on the target formula with line breaks to obtain a typeset formula, wherein, in the case where a sub-formula of the typeset formula includes the formula unit, the formula unit in the sub-formula is a complete unit, and then the typeset formula is displayed. Thus, the target formula can be displayed hierarchically, the composition of the target formula can be efficiently determined, and the integrity of the formula unit in the target formula can be efficiently determined, thereby improving the efficiency of determining the relationship between the formula units in the target formula in the document, thereby, in terms of editing, debugging, reading, and understanding the target formula, it is beneficial to improve the efficiency of determining whether the target formula in the document is accurate, and avoid the loss of equipment resources caused by repeated adjustments to the target formula.

[0192] Figure 2 A flow chart of another method for typesetting and displaying formulas in a document provided in an embodiment of the present application. Figure 2 As shown, the method specifically includes:

[0193] Step 201, obtaining a target formula in a document.

[0194] In this embodiment, step 201 and Figure 1 Step 101 in the corresponding embodiment is basically the same and will not be described again here.

[0195] Step 202, determining the position of at least one preset character among a plurality of characters constituting the target formula to obtain a position set, wherein the preset character is used to separate the complete formula unit.

[0196] In this embodiment, the preset characters may include at least one of the following: parameter separators in functions (for example, ","), operators (for example, "+", "-", "×", "÷", etc.), comparison operators (for example, "=", ">", "<"), separators for functions and parameters (for example, different types of brackets: "(", ")", "{", "}"), etc.

[0197] The position set may be a set of positions of at least one preset character among a plurality of characters constituting the target formula.

[0198] Step 203: Determine a target line break point of the target formula based on the positions in the position set.

[0199] In this embodiment, the target line break point may represent the line break point of the target formula.

[0200] Here, a variety of methods may be used to determine the target line break point of the target formula based on the position in the position set.

[0201] As an example, all or part of the positions in the position set may be determined as the target line break points of the target formula.

[0202] Step 204, performing line break typesetting processing on the target formula according to the target line break point to obtain a typeset formula.

[0203] In this embodiment, after determining one or more target line break points, the target formula may be subjected to line break typesetting processing at the one or more target line break points, thereby obtaining a typeset formula.

[0204] In one embodiment, the typesetting process of performing a line break on the target formula at the target line break point may include: during typesetting, adding a line break character after the target line break point, so that the formula editor typesets the characters after the line break character to the next line based on the line break character. In this embodiment, when writing the typesetting formula as the target formula in the document, the line break character in the typesetting formula is deleted to obtain the target formula.

[0205] In another embodiment, the typesetting process of performing line break processing on the target formula at the target line break point may include: when encountering the target line break point during typesetting, typeset the characters after the target line break point to the next line. Since no extra line break characters are inserted into the formula after typesetting, there is no risk that the written target formula does not comply with the formula expression rules due to the extra line break characters, thereby becoming an illegal formula.

[0206] Step 205, displaying the typeset formula.

[0207] In this embodiment, step 205 and Figure 1 Step 103 in the corresponding embodiment is basically the same and will not be described again here.

[0208] In some optional implementations of this embodiment, the following method may be used to determine the target line break point of the target formula based on the position in the position set:

[0209] In the first step, for a position in the position set, adjacent characters of the preset character at the position and positions between the preset characters at the position in the target formula are determined as candidate points corresponding to the position.

[0210] The adjacent characters are: the preceding character of the preset character, and / or the succeeding character of the preset character.

[0211] In the second step, a target line break point of the target formula is determined from candidate points corresponding to each position in the position set.

[0212] In this embodiment, the target line break point can be after the preset character or before the preset character, that is, the preset character can be divided into the same row as the previous formula unit or into the next row, and there is no limitation on this.

[0213] It can be understood that in the above optional implementation method, the target formula can be typeset with line breaks only at the candidate points corresponding to the positions of the preset characters. Since the preset characters are used to separate the complete formula units, this can improve the integrity of the formula unit segmentation, thereby further improving the efficiency of determining whether the formula in the document is accurate.

[0214] Moreover, by determining the target line break point in at least part of the candidate points, multiple and multi-level line break methods can be implemented, so that the typesetting effect of the typesetting formula obtained by typesetting processing is more diversified and meets different reading requirements. For example, the debugged formula unit can be set to be folded for display, that is, the target line break point is no longer set in the debugged formula unit, so that the display of the formula is more concise, and other formula units that need to be debugged are highlighted, avoiding the need to frequently scroll the content in the formula editor, facilitating user debugging, and reducing the resource loss of the device.

[0215] In some application scenarios of the above optional implementations, the following method may be used to determine the target line break point of the target formula from the candidate points corresponding to the respective positions in the position set:

[0216] For a position in the position set, based on the role of the preset character located at the position in the target formula, it is determined whether to determine the candidate point corresponding to the position as the line break point of the target formula.

[0217] Here, in the target formula, the same preset character may have different functions.

[0218] For example, for the preset character ":", when the target formula includes "A1:A11", the role of the preset character in the above target formula may be "combining the cell range A1-A11 for calculation"; when the target formula includes "a:b", the role of the preset character in the above target formula may be "calculating the ratio of a to b". In this case, it is not necessary to determine the candidate point corresponding to the position of the preset character ":" in "A1:A11" as the line break point of the target formula; the candidate point corresponding to the position of the preset character ":" in "a:b" can be determined as the line break point of the target formula.

[0219] For another example, when “:” is in quotation marks (such as “”), it can be indicated that the “:” belongs to a character string rather than an address reference symbol.

[0220] In practice, it is possible to determine whether to use the candidate point corresponding to the response position as a line break point according to the different roles of each preset character in the target formula. In some examples, the role of the preset character in the target formula can be determined by the context of the preset character in the target formula. For example, when it is determined that the preset character ":" is in quotation marks (such as ""), it is determined that the role of the ":" is one of the characters in the string.

[0221] It can be understood that in the above application scenario, it can be determined whether to determine the candidate point corresponding to the position as the line break point of the target formula according to the role of the preset character in the target formula. In this way, different line break strategies can be used for preset characters with different roles, thereby further improving the integrity of formula unit segmentation, thereby further improving the efficiency of determining whether the formula in the document is accurate.

[0222] In some application scenarios of the above optional implementation methods, the typeset formula may be displayed in the following manner: displaying the typeset formula through a formula editor.

[0223] On this basis, the target line break point of the target formula can be determined from the candidate points corresponding to the respective positions in the position set in the following manner:

[0224] The first step is to determine the display width of the formula editor.

[0225] The formula editor is an editor for displaying the target formula. The display width of the formula editor may be a preset width, or a width determined by a user or other object by dragging a sidebar of a display area of ​​the formula editor.

[0226] The second step is to determine the row width of each row of sub-formulas of the target formula to obtain a row width set.

[0227] The row width of the sub-formula may represent the sum of the widths of the formula cells in the sub-formula, or may represent the sum of the widths of the formula cells in the sub-formula and the widths of the content annotations of the sub-formula.

[0228] The third step is to determine the target line break point of the target formula from the candidate points corresponding to the respective positions in the position set based on the display width and the line width set.

[0229] Here, multiple methods can be used to determine the target line break point of the target formula from the candidate points corresponding to the positions in the position set based on the display width and the line width set. Please refer to the following description for details, which will not be repeated here.

[0230] In addition, during the process of editing the target formula, the line width corresponding to each sub-formula may also change due to the increase or decrease of characters, the enlargement or reduction of character font size, the increase of content annotations, etc., thereby changing the number of sub-formulas in the formula after typeset. In this way, automatic typesetting can be achieved during the editing process.

[0231] In addition, during the process of editing the target formula, due to the change in the display width of the formula editor, the row width corresponding to each sub-formula will be greater than the display width, resulting in incomplete display of the row, or the row width corresponding to each sub-formula will be less than the display width, resulting in excessive blank areas in the horizontal direction of the formula editor, resulting in a waste of display space. Therefore, the row width corresponding to each sub-formula can also change with the display width, thereby changing the number of sub-formulas in the formatted formula, thereby achieving automatic formatting during the editing process, and the formatted formula of the automatic formatting conforms to the display space of the formula editor.

[0232] It can be understood that in the above application scenario, based on the display width of the formula editor and the row width set of the current typeset formula, the target line break point of the target formula can be determined from the candidate points corresponding to each position in the position set, and then the target formula can be typeset. In this way, it can be ensured that the typesetting style of the typeset formula is more closely matched with the display width and row width set of the formula editor.

[0233] In some cases of the above application scenarios, the following method may be used to determine the target line break point of the target formula from the candidate points corresponding to the respective positions in the position set based on the display width and the line width set:

[0234] In the first step, when the line width set includes a target line width greater than the display width, the position of the first character in the sub-formula corresponding to the target line width is determined from the position set to obtain a first position subset.

[0235] The first character is a preset character of the next level of line break priority of the current line break priority corresponding to the target line width.

[0236] The target row width may be at least one row width in the row width set that is greater than the display width. Each row width may correspond to a sub-formula.

[0237] In addition, each preset character in the formula unit may correspond to a line break priority. The line break priority of each preset character in a single or multiple formula units at the same nesting level is the same. The line break priority of each preset character in the formula unit at the outer nesting level is higher than the line break priority of each preset character in the formula unit at the inner nesting level.

[0238] For example, formula cells can be nested in formula cells. For example, for the formula cell "SUM(VLOOKUP(A1, B1:C10, 2, FLASE), 1)" (when the entire content of the formula cell is displayed in the same row, the formula cell can also be used as a sub-formula), it can be further split to obtain two formula cells "VLOOKUP(A1, B1:C10, 2, FLASE)" and "1" (hereinafter referred to as sub-cells, or sub-formula cells). Therefore, if a formula cell can be further split to obtain sub-cells, then it can be determined that the formula cell has nested formula cells; if a formula cell cannot be further split to obtain sub-cells, then it can be determined that the formula cell does not have nested formula cells.

[0239] For the nested formula cell “SUM(VLOOKUP(A1, B1:C10, 2, FLASE), 1)”, the nested formula cells from the outside to the inside may be, for example: “SUM”, “VLOOKUP”, “A1, B1:C10, 2, FLASE”, “1”. Therefore, the line break priority of the preset character “(” used to separate “SUM” and “VLOOKUP” is higher than the line break priority of the preset character “(” used to separate “VLOOKUP” and “A1, B1:C10,2,FLASE”, and the line break priority of the preset character “,” used to separate “A1, B1:C10,2,FLASE” and “1”. The formula cell “A1, B1:C10,2,FLASE” can be further split into four formula cells “A1”, “B1:C10”, “2” and “FLASE”, which belong to the same nesting level. Therefore, the line break priority of the preset character “,” used to separate “A1” and “B1:C10”, the preset character “,” used to separate “B1:C10” and “2”, and the preset character “,” used to separate “2” and “FLASE” are the same, but lower than the line break priority of the preset character “,” used to separate “A1, B1:C10,2,FLASE” and “1”.

[0240] Each line width (including the target line width) may correspond to a current line break priority. The current line break priority corresponding to the line width may indicate: the line break priority when the width of the corresponding sub-formula is the line width. In other words, the current line break priority corresponding to the line width may ensure that the sub-formula corresponding to the line width is not further split and wrapped (i.e., as one line instead of two or more lines), and may ensure that the line where the sub-formula is located does not contain other characters except the sub-formula.

[0241] In some examples, preset characters with different line break priorities can be determined according to different numbers of levels, wherein the number of levels can be calculated and determined by the above-mentioned execution entity, and can also be set by users and other objects. For example, users and other objects can set the number of levels by clicking "Increase Level" or "Decrease Level" buttons.

[0242] Take the target formula "=SUM(VLOOKUP(A1,B1:C10,2,FLASE),1)" as an example to achieve the following multiple line breaks effect.

[0243] First line break:

[0244] "=SUM(

[0245] VLOOKUP(A1,B1:C10,2,FLASE), 1

[0247] )”

[0248] Second line break:

[0249]

[0250] For example, for the sub-formula A "VLOOKUP(A1, B1:C10, 2, FLASE)" after the first line break in the above example, it can correspond to the row width A' and the current line break priority A". Among them, the current line break priority A" can be the line break priority of the preset character a "(" used to separate "SUM" and "VLOOKUP". The next level of line break priority of the current line break priority A" is recorded as the line break priority A"'. Then, in this case, the first character in the sub-formula A can be: the preset character with the line break priority A"', for example, the preset character "(" used to separate "VLOOKUP" and "A1", the preset character "," used to separate "A1" and "B1:C10", the preset character "," used to separate "B1:C10" and "2", and the preset character "," used to separate "2" and "FLASE".

[0251] In the second step, the candidate points corresponding to the positions in the first position subset are determined as the target line break points of the target formula.

[0252] Here, after the target formula is formatted with line breaks according to the target line break points, the sub-formulas in the formatted formula will change accordingly. For example, the number of sub-formulas may increase. Accordingly, the values ​​and number of row widths in the row width set will also change accordingly, thereby obtaining an updated row width set.

[0253] In the case where the updated row width set includes a target row width that is greater than the display width, the first and second steps mentioned above can be further performed based on the updated row width set until the obtained row width set does not include the target row width, that is, each row width in the obtained row width set is less than or equal to the display width.

[0254] In the second step, the candidate points corresponding to the positions in the first position subset are determined as the target line break points of the target formula.

[0255] It can be understood that in the above optional implementation, when the row width set includes a row width greater than the display width, the sub-formula corresponding to the row width greater than the display width can be further wrapped, thereby further reducing the row width of the sub-formula, thereby ensuring that the typesetting style of the formula after typeset is more closely matched with the display width of the formula editor.

[0256] In some cases of the above application scenarios, the following method may be used to determine the target line break point of the target formula from the candidate points corresponding to the respective positions in the position set based on the display width and the line width set:

[0257] In the first step, when the line width set includes a target line width greater than the display width, the position of the second character in the target formula is determined from the position set to obtain a first position subset.

[0258] The second character is a preset character of the next level of line break priority of the current line break priority corresponding to the line width set.

[0259] Here, the specific meanings of the line break priority (including the current line break priority and the next level line break priority), the target line width, and the nesting of formula cells can be referred to the above description, which will not be repeated here.

[0260] In addition, in some cases, the current line break priority corresponding to each sub-formula in the target formula may be the same. In other words, the current line break priority corresponding to each sub-formula may be determined as a preset line break priority, for example, sub-formula 1 in the target formula corresponds to current line break priority 1, and sub-formula 2 in the target formula also corresponds to current line break priority 1. The line break priority of the preset characters in sub-formula 1 and sub-formula 2 may be determined based on the current line break priority 1 according to their hierarchical relationship.

[0261] Thus, the same current line break priority (eg, current line break priority 1) corresponding to each sub-formula in the target formula may be determined as the current line break priority corresponding to the line width set.

[0262] The first position subset may be: a set of positions of the second character in the target formula in the position set.

[0263] In the second step, the candidate points corresponding to the positions in the first position subset are determined as the target line break points of the target formula.

[0264] Here, after the target formula is formatted with line breaks according to the target line break points, the sub-formulas in the formatted formula will change accordingly. For example, the number of sub-formulas may increase and the width of the sub-formulas may change. Accordingly, the values ​​and number of row widths in the row width set at this time will also change accordingly, thereby obtaining an updated row width set.

[0265] In the case where the updated row width set includes a target row width that is greater than the display width, the first and second steps mentioned above can be further performed based on the updated row width set until the obtained row width set does not include the target row width, that is, each row width in the obtained row width set is less than or equal to the display width.

[0266] It can be understood that in the above optional implementation, when the row width set includes a row width greater than the display width, the current sub-formulas can be further wrapped, thereby further reducing the row width of each sub-formula, thereby ensuring that the typesetting style of the formula after typeset is more closely matched with the display width of the formula editor.

[0267] In some optional implementations of this embodiment, the following method may be used to determine the target line break point of the target formula based on the position in the position set:

[0268] In the first step, when the target formula includes nested formula units, the line break priority of each preset character at each nested level in the nested formula units is determined in a sub-formula.

[0269] The line breaking priorities of the preset characters in a single or multiple formula units at the same nesting level are the same. The line breaking priorities of the preset characters in the formula units at the outer nesting level are higher than the line breaking priorities of the preset characters in the formula units at the inner nesting level.

[0270] Here, the specific meanings of the line break priority (including the current line break priority and the next level line break priority), the target line width, and the nesting of formula cells can be referred to the above description, which will not be repeated here.

[0271] In the second step, the positions of the preset characters whose line break priority is higher than the target priority are determined from the position set to obtain a second position subset.

[0272] The target priority may be a line break priority determined by a user or other object, or may be a line break priority determined by the execution subject through calculation.

[0273] In some cases, the target priority can be used to ensure that the line width of each sub-formula in the formatted formula is smaller than the width of the display area of ​​the formula editor.

[0274] The second position subset may be a set of positions of preset characters having a line break priority higher than a target priority in the position set.

[0275] The third step is to determine the position in the second position subset as the target line break point of the target formula.

[0276] It can be understood that in the above optional implementation, it can be ensured that the positions corresponding to the preset characters with the same line break priority are all used as the target line break points of the target formula, or that none of them are used as the target line break points of the target formula. In this way, the logical relationship between the sub-formulas in the formula after typesetting can be further clarified, thereby further improving the efficiency of determining whether the formula in the document is accurate. In addition, by preferentially breaking the line at the position corresponding to the preset character with a higher line break priority, the target formula can be broken from the outside to the inside, thereby further clarifying the logical relationship between the sub-formulas in the formula after typesetting, thereby further improving the efficiency of determining whether the formula in the document is accurate.

[0277] It should be noted that, in addition to the above contents, this embodiment may also include Figure 1 The corresponding technical features described in the corresponding embodiments are realized Figure 1 For details on the technical effects of the typesetting and display methods of the formulas in the document shown, please refer to Figure 1 For the sake of brevity, the relevant description is not repeated here.

[0278] The method for typesetting and displaying formulas in a document provided in an embodiment of the present application can more accurately and quickly determine the target line break points by using preset characters to separate complete formula units, thereby improving the efficiency of line breaking for the target formula and further improving the efficiency of determining whether the formula in the document is accurate.

[0279] The following is an illustrative description of the embodiments of the present application, but it should be noted that the embodiments of the present application may have the features described below, but the following description does not constitute a limitation on the scope of protection of the embodiments of the present application.

[0280] When using table formulas, multiple functions are often used in combination to form nested formulas. Complex formulas have many characters and no clear distinction between different functions and parameters, which makes it difficult to debug, read, and understand the meaning of formulas.

[0281] In the existing solution, the formula is usually copied to a text editor or code editor, and carriage return, space, and tab are manually entered to achieve the indentation effect. Use the add note function as a formula comment. However, the above solution has the following problems: after modifying the formula content, it needs to be pasted back into the ET (ET file is a type of spreadsheet file) cell again. It is impossible to know whether there are syntax errors in the formula in time, and it is impossible to see the latest calculation results in time, and it is difficult to confirm the correctness of the formula. In addition, the interactive behavior is inconvenient during the formula modification process. It is impossible to select cells as selections and obtain formula parameter prompts, which greatly increases the difficulty of formula writing. Indentation and line breaks are all manual operations, which are inefficient. When the indentation level needs to be adjusted, the operation cost is high. The remarks are at the cell level and cannot correspond to a sub-function or parameter of the formula (that is, the above-mentioned formula unit), making it difficult to help readers understand the meaning of the formula.

[0282] In view of this, this solution provides a formula editor in the table that supports automatic typesetting, and also supports formula explanation, completion, and annotation, etc. This improves the efficiency of reading, writing, and debugging complex formulas in the table.

[0283] Specifically, see Figure 3A-3J , Figure 3A-3J A schematic diagram of an application scenario of a method for typesetting and displaying formulas in a document provided in an embodiment of the present application.

[0284] After opening the formula editor, use the editor width (i.e. the display width mentioned above) as the maximum width of a row (i.e. the width of each row in the row width set mentioned above is less than or equal to the display width mentioned above), use brackets, commas, function names, etc. as separators, add line breaks and indents to achieve the goal of viewing formulas in layers; after adjusting the editor width, recalculate the layering rules in real time to change the layout effect. Provide more fine-grained comments. During the formula writing process, you can write comments for a small section of the formula content (i.e. the sub-formula mentioned above). Automatic layout of table formulas is achieved to improve readability; support annotations for partial formula content.

[0285] 1) Automatic layout

[0286] a. Actual renderings and rules:

[0287] According to the current sidebar width (that is, the display width mentioned above), if the width is sufficient for full display, it will not be wrapped at all and will be displayed in one line; if it exceeds the current width (that is, the target line width is included in the line width set), it will start to wrap and indent.

[0288] The line break points (also known as the target line break points mentioned above) are: addition, subtraction, multiplication, division, equal sign, comma, and function.

[0289] Start folding from the outermost function or addition, subtraction, multiplication, division, and equal signs, and put all the next level parameters on a line.

[0290] See also Figure 3A-3D , Figure 3A-3D A schematic diagram of a typesetting and display method for formulas in a document provided in an embodiment of the present application shows typesetting formulas corresponding to different display widths. The typesetting formulas corresponding to different display widths are described below by way of example.

[0291] Example: =if(SUM(VLOOKUP(A1,B1:C10,2,FLASE),1)=10,"Correct","Failed");

[0292] Initial: One line displays the status.

[0293] If a line of content exceeds the width of the editor, the three parameters of if will be wrapped first.

[0294] If after the line break, one or more lines are still too wide, then the next level of line break and indentation will be performed.

[0295] For example, after folding, if SUM(VLOOKUP(A1, A1:C10, 2, FLASE), 1)=10 is too long, then wrap at the equal sign. If it is still too long, wrap SUM. If it is still too long, wrap VLOOKUP. At this point, there is no longer a point where you can wrap, and the wrapping ends.

[0296] Interaction: Provides three ways to adjust the layout effect.

[0297] The formula is not edited, drag to change the sidebar width, and automatically layout according to the width.

[0298] During formula editing, typesetting is triggered automatically. Figure 3E .

[0299] The editing process has no hierarchy or indentation, see Figure 3F .

[0300] Click Optimize Layout to trigger formula layout.

[0301] Freely increase or decrease levels and adjust the layout effect, see Figure 3G .

[0302] Initial state, a whole line, see Figure 3H .

[0303] No need to adjust the width, click to add folds, see Fig. 3I .

[0304] For multiple folding effects, see Figure 3J .

[0305] 2) Formula annotation

[0306] In the sidebar, there is a comment function. Click it to add two double slashes to the current line. The font turns gray and the input will not be included in the actual calculation content of the formula, but it can help understand the meaning of the formula.

[0307] You can also insert a preset trigger character to trigger the entry of a comment, for example, you can directly enter a double slash to enter a comment.

[0308] In addition, this solution can also display the intermediate value of the formula (that is, the above calculation result). Figure 3K , Figure 3L .

[0309] It should be noted that, in addition to the contents recorded above, this embodiment may also include the technical features described in the above embodiments, so as to achieve the technical effects of the typesetting and display method of the formulas in the document shown above. Please refer to the above description for details. For the sake of brevity, it will not be repeated here.

[0310] The method for typesetting and displaying formulas in documents provided in the embodiments of the present application improves the efficiency and accuracy of reading complex formulas by providing a convenient and automatic typesetting method for multiple formulas. By providing a method for annotating the contents of a formula, it is easier for the formula writer to convey the meaning of the formula to the reader, and it is convenient to sort out and debug the logical relationship before and after during the writing process.

[0311] Figure 4 A schematic diagram of a structure of a device for typesetting and displaying formulas in a document provided in an embodiment of the present application. Specifically comprising:

[0312] A first acquisition unit 401 is used to acquire a target formula in a document;

[0313] A first line break unit 402 is used to perform line break typesetting processing on the target formula according to the integrity of the formula unit to obtain a typeset formula, wherein when a sub-formula of the typeset formula includes the formula unit, the formula unit in the sub-formula is a complete unit;

[0314] The first display unit 403 is used to display the typeset formula.

[0315] In a possible implementation, performing line break typesetting processing on the target formula according to the integrity of the formula unit to obtain a typeset formula includes:

[0316] Determine the position of at least one preset character among a plurality of characters constituting the target formula to obtain a position set, wherein the preset character is used to separate complete formula units;

[0317] Determining a target line break point of the target formula based on the positions in the position set;

[0318] According to the target line break point, the target formula is subjected to line break typesetting processing to obtain a typeset formula.

[0319] In a possible implementation, determining the target line break point of the target formula based on the position in the position set includes:

[0320] For a position in the position set, the adjacent characters of the preset character at the position and the positions between the preset characters at the position in the target formula are determined as candidate points corresponding to the position; wherein the adjacent characters are: the preceding character of the preset character and / or the succeeding character of the preset character;

[0321] A target line break point of the target formula is determined from candidate points corresponding to respective positions in the position set.

[0322] In a possible implementation, determining the target line break point of the target formula from the candidate points corresponding to the respective positions in the position set includes:

[0323] For a position in the position set, based on the role of the preset character located at the position in the target formula, it is determined whether to determine the candidate point corresponding to the position as the line break point of the target formula.

[0324] In a possible implementation, displaying the typeset formula includes:

[0325] Displaying the typeset formula by a formula editor; and

[0326] The step of determining the target line break point of the target formula from the candidate points corresponding to the respective positions in the position set includes:

[0327] Determining a display width of the formula editor, wherein the formula editor is an editor for displaying the target formula;

[0328] Determine the row width of each row of sub-formulas of the target formula to obtain a row width set;

[0329] Based on the display width and the line width set, a target line break point of the target formula is determined from candidate points corresponding to respective positions in the position set.

[0330] In a possible implementation, determining the target line break point of the target formula from candidate points corresponding to respective positions in the position set based on the display width and the line width set includes:

[0331] In a case where the line width set includes a target line width greater than the display width, determining the position of a first character in a sub-formula corresponding to the target line width from the position set to obtain a first position subset, wherein the first character is a preset character of a next level of line break priority of a current line break priority corresponding to the target line width;

[0332] The candidate points corresponding to the positions in the first position subset are determined as the target line break points of the target formula.

[0333] In a possible implementation, determining the target line break point of the target formula from candidate points corresponding to respective positions in the position set based on the display width and the line width set includes:

[0334] In a case where the line width set includes a target line width greater than the display width, determining a position of a second character in the target formula from the position set to obtain a first position subset, wherein the second character is a preset character of a next level of line break priority of a current line break priority corresponding to the line width set;

[0335] The candidate points corresponding to the positions in the first position subset are determined as the target line break points of the target formula.

[0336] In a possible implementation, determining the target line break point of the target formula based on the position in the position set includes:

[0337] In the case where the target formula includes nested formula units, determining the line break priority of each preset character at each nested level in the nested formula units in the sub-formula; wherein the line break priority of each preset character in a single or multiple formula units at the same nested level is the same; and the line break priority of each preset character in a formula unit at an outer nested level is higher than the line break priority of each preset character in a formula unit at an inner nested level;

[0338] From the position set, determine the position of the preset character whose line break priority is higher than the target priority to obtain a second position subset;

[0339] A position in the second position subset is determined as a target line break point of the target formula.

[0340] In a possible implementation, the document includes a table, and the table includes cells; and

[0341] The device also includes:

[0342] A second display unit (not shown in the figure) is used to use the target formula or the typeset formula as a display formula and display the display formula;

[0343] A first receiving unit (not shown in the figure), used for receiving a selection operation on a cell in the table during editing of the display formula;

[0344] an adjusting unit (not shown in the figure), configured to adjust the displayed formula in response to the selection operation using the address of the cell, the formula in the cell, or the calculation result of the formula in the cell to obtain an updated formula;

[0345] The third display unit (not shown in the figure) is used to display the updated formula.

[0346] In a possible implementation, after displaying the typeset formula, the device further includes:

[0347] A second receiving unit (not shown in the figure) is used for receiving an operation of adding a content annotation to a sub-formula in the typeset formula in response to a selection operation on the sub-formula;

[0348] The fourth display unit (not shown in the figure) is used to display the added content annotation.

[0349] In a possible implementation manner, before receiving the operation of adding a content annotation to the sub-formula, the apparatus further includes:

[0350] An associating unit (not shown in the figure), used to establish an associative relationship between the sub-formula and the content annotation;

[0351] The displaying of the typeset formula includes:

[0352] Determine the sub-formula of each row in the typeset formula;

[0353] In a case where it is determined based on the association relationship that the sub-formula is associated with a content annotation, the content annotation associated with the sub-formula is displayed.

[0354] In a possible implementation, after displaying the typeset formula, the device further includes:

[0355] The fifth display unit (not shown in the figure) is used to display the calculation result of the formula cell in response to the target operation on the formula cell in the typeset formula.

[0356] The typesetting and display device of the formula in the document provided in this embodiment can be as follows: Figure 4 The device for typesetting and displaying formulas in a document shown in the figure can execute all the steps of the method for typesetting and displaying formulas in each document described above, thereby realizing the technical effect of the method for typesetting and displaying formulas in each document described above. For details, please refer to the above related description. For the sake of brevity, it will not be elaborated here.

[0357] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, Figure 5 The electronic device 500 shown includes: at least one processor 501, a memory 502, at least one network interface 504 and other user interfaces 503. The various components in the electronic device 500 are coupled together via a bus system 505. It is understood that the bus system 505 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 505 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 505 is not shown in FIG. Figure 5 Various buses are labeled as bus system 505 .

[0358] The user interface 503 may include a display, a keyboard, or a pointing device (eg, a mouse, a trackball, a touch pad, or a touch screen).

[0359] It can be understood that the memory 502 in the embodiment of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct RAM bus random access memory (DRRAM). The memory 502 described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0360] In some implementations, the memory 502 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system 5021 and an application program 5022 .

[0361] Among them, the operating system 5021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application 5022 includes various application programs, such as a media player (Media Player), a browser (Browser), etc., which are used to implement various application services. The program for implementing the method of the embodiment of the present application can be included in the application 5022.

[0362] In this embodiment, by calling the program or instruction stored in the memory 502, specifically, the program or instruction stored in the application 5022, the processor 501 is used to execute the method steps provided by each method embodiment, for example, including:

[0363] Get the target formula in the document;

[0364] According to the integrity of the formula unit, the target formula is subjected to line break typesetting processing to obtain a typeset formula, wherein, in the case where a sub-formula of the typeset formula includes the formula unit, the formula unit in the sub-formula is a complete unit;

[0365] Display the typeset formula.

[0366] The method disclosed in the above embodiment of the present application can be applied to the processor 501, or implemented by the processor 501. The processor 501 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 501. The above processor 501 can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to execute, or the hardware and software units in the decoding processor can be executed. The software unit can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 502, and the processor 501 reads the information in the memory 502 and completes the steps of the above method in combination with its hardware.

[0367] It is understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPDevice, DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the above functions of the present application, or a combination thereof.

[0368] For software implementation, the technology described above in this article can be implemented by a unit that performs the functions described above in this article. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.

[0369] The electronic device provided in this embodiment may be Figure 5 The electronic device shown in can execute all steps of the method for typesetting and displaying formulas in the documents described above, thereby achieving the technical effects of the method for typesetting and displaying formulas in the documents described above. Please refer to the above related description for details. For the sake of brevity, it will not be repeated here.

[0370] The embodiment of the present application also provides a storage medium (computer-readable storage medium). The storage medium here stores one or more programs. The storage medium may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a read-only memory, a flash memory, a hard disk or a solid-state drive; the memory may also include a combination of the above-mentioned types of memory.

[0371] When one or more programs in the storage medium can be executed by one or more processors, the above-mentioned method of typesetting and displaying formulas in the document executed on the electronic device side can be implemented.

[0372] The processor is used to execute the typesetting and display program of the formula in the document stored in the memory to implement the following steps of the typesetting and display method of the formula in the document executed on the electronic device side:

[0373] Get the target formula in the document;

[0374] According to the integrity of the formula unit, the target formula is subjected to line break typesetting processing to obtain a typeset formula, wherein, in the case where a sub-formula of the typeset formula includes the formula unit, the formula unit in the sub-formula is a complete unit;

[0375] Display the typeset formula.

[0376] The professionals should also be further aware that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0377] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0378] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0379] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.

Claims

1. A method for typesetting and displaying formulas in a document, characterized in that: The method comprises: Get the target formula in the document; According to the integrity of the formula unit, the target formula is subjected to line break typesetting processing to obtain a typeset formula, wherein, in the case where a sub-formula of the typeset formula includes the formula unit, the formula unit in the sub-formula is a complete unit; Display the typeset formula.

2. The method according to claim 1, characterized in that The step of performing line break typesetting processing on the target formula according to the integrity of the formula unit to obtain a typesetting formula includes: Determine the position of at least one preset character among a plurality of characters constituting the target formula to obtain a position set, wherein the preset character is used to separate complete formula units; Determining a target line break point of the target formula based on the positions in the position set; According to the target line break point, the target formula is subjected to line break typesetting processing to obtain a typeset formula.

3. The method according to claim 2, characterized in that The step of determining a target line break point of the target formula based on the position in the position set includes: For a position in the position set, the adjacent characters of the preset character at the position and the positions between the preset characters at the position in the target formula are determined as candidate points corresponding to the position; wherein the adjacent characters are: the preceding character of the preset character and / or the succeeding character of the preset character; A target line break point of the target formula is determined from candidate points corresponding to respective positions in the position set.

4. The method according to claim 3, characterized in that The step of determining the target line break point of the target formula from the candidate points corresponding to the respective positions in the position set includes: For a position in the position set, based on the role of the preset character located at the position in the target formula, it is determined whether to determine the candidate point corresponding to the position as the line break point of the target formula.

5. The method according to claim 3, characterized in that: The displaying of the typeset formula includes: Displaying the typeset formula by a formula editor; and The step of determining the target line break point of the target formula from the candidate points corresponding to the respective positions in the position set includes: Determining a display width of the formula editor, wherein the formula editor is an editor for displaying the target formula; Determine the row width of each row of sub-formulas of the target formula to obtain a row width set; Based on the display width and the line width set, a target line break point of the target formula is determined from candidate points corresponding to respective positions in the position set.

6. The method according to claim 5, characterized in that The step of determining the target line break point of the target formula from the candidate points corresponding to the respective positions in the position set based on the display width and the line width set includes: In a case where the line width set includes a target line width greater than the display width, determining the position of a first character in a sub-formula corresponding to the target line width from the position set to obtain a first position subset, wherein the first character is a preset character of a next level of line break priority of a current line break priority corresponding to the target line width; The candidate points corresponding to the positions in the first position subset are determined as the target line break points of the target formula.

7. The method according to claim 5, characterized in that The step of determining the target line break point of the target formula from the candidate points corresponding to the respective positions in the position set based on the display width and the line width set includes: In a case where the line width set includes a target line width greater than the display width, determining a position of a second character in the target formula from the position set to obtain a first position subset, wherein the second character is a preset character of a next level of line break priority of a current line break priority corresponding to the line width set; The candidate points corresponding to the positions in the first position subset are determined as the target line break points of the target formula.

8. The method according to claim 2, characterized in that: The step of determining a target line break point of the target formula based on the position in the position set includes: In the case where the target formula includes nested formula units, determining the line break priority of each preset character at each nested level in the nested formula units in the sub-formula; wherein the line break priority of each preset character in a single or multiple formula units at the same nested level is the same; and the line break priority of each preset character in a formula unit at an outer nested level is higher than the line break priority of each preset character in a formula unit at an inner nested level; From the position set, determine the position of the preset character whose line break priority is higher than the target priority to obtain a second position subset; A position in the second position subset is determined as a target line break point of the target formula.

9. The method according to claim 1, characterized in that: The document includes a table, the table includes cells; and The method further comprises: Using the target formula or the typeset formula as a display formula, and displaying the display formula; In the process of editing the display formula, receiving a selection operation on a cell in the table; In response to the selection operation, adjusting the display formula using the address of the cell, the formula in the cell, or the calculation result of the formula in the cell to obtain an updated formula; The updated formula is displayed.

10. The method according to claim 1, characterized in that After displaying the typeset formula, the method further includes: In response to a selection operation on a sub-formula in the typeset formula, receiving an operation of adding a content annotation to the sub-formula; Displays the added content annotation.

11. The method according to claim 10, before receiving the operation of adding a content annotation to the sub-formula, the method further comprises: Establishing an association relationship between the sub-formula and the content annotation; The displaying of the typeset formula includes: Determine the sub-formula of each row in the typeset formula; In a case where it is determined based on the association relationship that the sub-formula is associated with a content annotation, the content annotation associated with the sub-formula is displayed.

12. The method according to claim 1, characterized in that After displaying the typeset formula, the method further includes: In response to a target operation on a formula cell in the typeset formula, a calculation result of the formula cell is displayed.

13. A device for typesetting and displaying formulas in a document, characterized in that: The device comprises: A first acquisition unit, used for acquiring a target formula in a document; A first line break unit, configured to perform line break typesetting processing on the target formula according to the integrity of the formula unit to obtain a typeset formula, wherein, when a sub-formula of the typeset formula includes the formula unit, the formula unit in the sub-formula is a complete unit; The first display unit is used to display the typeset formula.

14. An electronic device, characterized in that: include: Memory for storing computer programs; A processor is used to execute a computer program stored in the memory, and when the computer program is executed, the method for typesetting and displaying formulas in the document of any one of claims 1 to 12 is implemented.

15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for typesetting and displaying formulas in the document of any one of claims 1 to 12 is implemented.